2
Array utility functions.
5
var foswiki; if (foswiki == undefined) foswiki = {};
9
Removes an object from an Array.
10
@param inArray : (required) Array to remove object from
11
@param inObject : (required) Object to remove from Array
13
remove:function(inArray, inObject) {
14
if (!inArray || !inObject) return null;
15
for (i=0; i<inArray.length; i++) {
16
if (inObject == inArray[i]) {
23
Creates an Array from a list of function arguments.
24
@param inArguments : function arguments
25
@param inStartIndex : (optional) the starting index in the list of function arguments
26
@return A new Array with elements from the passed function arguments.
28
The following code creates an Array of all arguments passed after inName:
30
function releaseProps(inName) {
31
var properties = foswiki.Array.convertArgumentsToArray(arguments, 1);
32
if (!properties) return;
33
_releaseProps(inName, properties);
37
convertArgumentsToArray:function(inArguments, inStartIndex) {
38
if (inArguments == undefined) return null;
39
var ilen = inArguments.length;
40
if (ilen == 0) return null;
43
if (isNaN(inStartIndex)) return null;
44
if (inStartIndex > ilen-1) return null;
48
for (var i = start; i < ilen; i++) {
49
list.push(inArguments[i]);
56
Determine the index of the (first) occurrence of an object in an array.
57
@param inArray : (Array) array to search
58
@param el : (Object) the object to find
59
@return The index number; -1 if the object is not found; null if no valid Array has been passed.
61
indexOf:function(inArray, el) {
62
if (!inArray || inArray.length == undefined) return null;
63
var i, ilen = inArray.length;
64
for (i=0; i<ilen; ++i) {
65
if (inArray[i] == el) return i;