Class: DuList

DuList

DuList helps manipulating JS Arrays and After Effects Collections the same way. It is faster than converting a Collection to an Array.
Other specific Adobe Lists in other Applications may be supported later.
The first item of a DuList is always at index 0, the last at index length-1.
Accessor is the DuList.at() method instead of Array.
List length is given by the DuList.length() method instead of a property.
DuList does not reimplement methods to add or remove items, use the source list instead with the DuList.list() property and the original methods (from the Collection instance or Array).
DuList can also be used as an iterator with iterator-like methods like DuList.next().
You can also run a function on each item with DuList.do().

new DuList()

D:/DEV_SRC/RxOT/DuAEF/DuESF/tools/build/output/DuESF.jsxinc, line 787
Constructs a new DuList object
Properties:
Name Type Description
isCollection boolean true if the original list is an After Effects Collection, false otherwise
isArray boolean true if the original list is an Array, false otherwise

Members

readonlyatEndBoolean

True if the iterator has reached the end.

readonlyatStartBoolean

True if the iterator is at the start.

readonlycurrentint

The current index of the iterator.

readonlyisArrayBoolean

True if the original list is an Array, false otherwise

readonlyisCollectionBoolean

True if the original list is an After Effects Collection, false otherwise.

readonlylistArray Collection

The original list, an Array or an After Effects Collection.

readonlyvalidBoolean

True if the iterator is between 0 and length-1. Note that on creation, the iterator is always invalid, but calling DuList.next() moves it to the beginning and makes it valid.

Methods

staticDuList.compare(array1, array2, floatPrecision){boolean}

D:/DEV_SRC/RxOT/DuAEF/DuESF/tools/build/output/DuESF.jsxinc, line 1671
Compares two arrays.
The items in the arrays must be compatible with the == operand
Name Type Default Description
array1 Array | Collection The array
array2 Array | Collection The array
floatPrecision int -1 optional The precision for (float) number comparison, number of decimals. Set to -1 to not use.
Deprecated
  • Yes
Returns:
Type Description
boolean true if the two arrays contain the same values

staticDuList.getDuplicates(arr){Array}

D:/DEV_SRC/RxOT/DuAEF/DuESF/tools/build/output/DuESF.jsxinc, line 1620
Returns all duplicated values found in the array
Name Type Description
arr Array The array
Deprecated
  • Yes
Returns:
Type Description
Array The duplicated values

staticDuList.hasDuplicates(arr){boolean}

D:/DEV_SRC/RxOT/DuAEF/DuESF/tools/build/output/DuESF.jsxinc, line 1602
Checks if the array has duplicate values
Name Type Description
arr Array The array
Deprecated
  • Yes
Returns:
Type Description
boolean true if the array has duplicate values

staticDuList.indexOf(arr, value, comparisonFunction){int}

D:/DEV_SRC/RxOT/DuAEF/DuESF/tools/build/output/DuESF.jsxinc, line 1581
Gets the first index of a value in an Array, or -1 if not found
Name Type Description
arr Array The array
value * The value to find. Must be compatible with the == operand, or provide a comparison function
comparisonFunction function optional A function which compares two values which returns true if the values are considered the same.
Deprecated
  • Yes
Returns:
Type Description
int The index of the value, -1 if not found

staticDuList.isList(list){boolean}

D:/DEV_SRC/RxOT/DuAEF/DuESF/tools/build/output/DuESF.jsxinc, line 1547
Checks if this is an Array or an After Effects collection type or a DuList
Name Type Description
list Array | Collection The list to check
Returns:
Type Description
boolean true if this is a Cllection or an Array or a DuList

staticDuList.removeDuplicates(arr, comparisonFunction){Array}

D:/DEV_SRC/RxOT/DuAEF/DuESF/tools/build/output/DuESF.jsxinc, line 1641
Removes all duplicated values from the Array, and returns them
Name Type Description
arr Array The array
comparisonFunction function optional A function which compares two values which returns true if the values are considered the same.
Deprecated
  • Yes
Returns:
Type Description
Array The duplicated (and removed) values

append()

D:/DEV_SRC/RxOT/DuAEF/DuESF/tools/build/output/DuESF.jsxinc, line 1289
Alias for DuList.push()

appendUnique()

D:/DEV_SRC/RxOT/DuAEF/DuESF/tools/build/output/DuESF.jsxinc, line 1298

at(index){object}

D:/DEV_SRC/RxOT/DuAEF/DuESF/tools/build/output/DuESF.jsxinc, line 924
Accessor. First item is always 0, last is always length()-1
Does not move the iterator to the index; to move the iterator use DuList.goTo instead.
Name Type Description
index int The index of the item. If it is out of range (negative or > length()-1), returns null
Returns:
Type Description
object The item at the given index.

convertToArray()

D:/DEV_SRC/RxOT/DuAEF/DuESF/tools/build/output/DuESF.jsxinc, line 1140
Converts the stored list to an Array if it was a Collection.
This enables the modification of the list, but changes in the list will not be reflected in the application (if a layer is removed from the list, it is not removed in the application).

count()

D:/DEV_SRC/RxOT/DuAEF/DuESF/tools/build/output/DuESF.jsxinc, line 909
Alias for DuList.length()

do(callBack)

D:/DEV_SRC/RxOT/DuAEF/DuESF/tools/build/output/DuESF.jsxinc, line 1520
Executes a function on each item of the List
Name Type Description
callBack function The function to execute, which takes one parameter: an item of the list

equals(other, floatPrecision){boolean}

D:/DEV_SRC/RxOT/DuAEF/DuESF/tools/build/output/DuESF.jsxinc, line 1057
Compares two arrays.
The items in the arrays must be compatible with the == operand if you don't provide a comparison function
Name Type Default Description
other Array | Collection | DuList The other list
floatPrecision int -1 optional The precision for (float) number comparison, number of decimals. Set to -1 to not use.
Returns:
Type Description
boolean true if the two arrays contain the same values

first(){*}

D:/DEV_SRC/RxOT/DuAEF/DuESF/tools/build/output/DuESF.jsxinc, line 1130
Gets the first item in the list
Returns:
Type Description
* The first item, null if the list is empty.

getDuplicates(){DuList}

D:/DEV_SRC/RxOT/DuAEF/DuESF/tools/build/output/DuESF.jsxinc, line 991
Returns all duplicated values found in the list
Returns:
Type Description
DuList The duplicated values. An empty list for Ae Collections as they can't have duplicated items.

goTo(index){*}

D:/DEV_SRC/RxOT/DuAEF/DuESF/tools/build/output/DuESF.jsxinc, line 1433
Sets the iterator on the index
Name Type Description
index int The index
Returns:
Type Description
* The item at index, or null if the index is invalid

goToEnd(){Object}

D:/DEV_SRC/RxOT/DuAEF/DuESF/tools/build/output/DuESF.jsxinc, line 1456
Goes to the end of the Iterator
Returns:
Type Description
Object The item at the end, or null if length is 0

goToStart(){Object}

D:/DEV_SRC/RxOT/DuAEF/DuESF/tools/build/output/DuESF.jsxinc, line 1466
Goes to the start of the Iterator
Returns:
Type Description
Object The item at the start, or null if length is 0

hasDuplicates(){boolean}

D:/DEV_SRC/RxOT/DuAEF/DuESF/tools/build/output/DuESF.jsxinc, line 976
Checks if the list has duplicated values
Returns:
Type Description
boolean true if the list has duplicated values. Always false for Ae Collections as they can't have duplicated items.

indexOf(value, comparisonFunction){int}

D:/DEV_SRC/RxOT/DuAEF/DuESF/tools/build/output/DuESF.jsxinc, line 956
Gets the first index of a value, or -1 if not found
Name Type Description
value * The value to find. Must be compatible with the == operand if you don't provide a comparison function
comparisonFunction function optional A function which compares two values which returns true if the values are considered the same.
Returns:
Type Description
int The index of the value, -1 if not found

isEmpty(){boolean}

D:/DEV_SRC/RxOT/DuAEF/DuESF/tools/build/output/DuESF.jsxinc, line 1111
Returns true if the list is empty
Returns:
Type Description
boolean

join(separator){string}

D:/DEV_SRC/RxOT/DuAEF/DuESF/tools/build/output/DuESF.jsxinc, line 1351
Reimplementation of the Array.join function.
For collections, the name of the item will be used, or any other property which makes sense as a string list.
Name Type Description
separator string The separator to use
Returns:
Type Description
string The new length of the list.

last(){*}

D:/DEV_SRC/RxOT/DuAEF/DuESF/tools/build/output/DuESF.jsxinc, line 1120
Gets the last item in the list
Returns:
Type Description
* The last item, null if the list is empty.

length(){int}

D:/DEV_SRC/RxOT/DuAEF/DuESF/tools/build/output/DuESF.jsxinc, line 904
Returns the number of items in the list
Returns:
Type Description
int The number of items.

merge(arr){int}

D:/DEV_SRC/RxOT/DuAEF/DuESF/tools/build/output/DuESF.jsxinc, line 1314
Merges the new array to the current list.
Note that to the contrary of the Array.concat() method, this does not create a new list, but modifies the current one in place.
The internal list may be converted to an Array if needed.
Name Type Description
arr Array.<any> The other array.
Returns:
Type Description
int The new length of the list.

mergeUnique(arr, comparisonFunction){int}

D:/DEV_SRC/RxOT/DuAEF/DuESF/tools/build/output/DuESF.jsxinc, line 1333
Merges the new array to the current list.
Will only add items if they're not already in the list.
Note that to the contrary of the Array.concat() method, this does not create a new list, but modifies the current one in place.
The internal list may be converted to an Array if needed.
Name Type Description
arr Array.<any> The other array.
comparisonFunction function optional A function which compares two values which returns true if the values are considered the same.
Returns:
Type Description
int The new length of the list.

next(){Object}

D:/DEV_SRC/RxOT/DuAEF/DuESF/tools/build/output/DuESF.jsxinc, line 1477
Increments the Iterator
Must be called at least once to validate the iterator
Returns:
Type Description
Object The next item, or null if there isn't

previous(){Object}

D:/DEV_SRC/RxOT/DuAEF/DuESF/tools/build/output/DuESF.jsxinc, line 1499
Decrements the Iterator if it's called while valid is false, goes to the end
Returns:
Type Description
Object The previous item, or null if there isn't

push(element0, element1, elementN){int}

D:/DEV_SRC/RxOT/DuAEF/DuESF/tools/build/output/DuESF.jsxinc, line 1251
Adds one or more elements to the end of the list and returns the new length of the list.
The internal list may be converted to an Array if needed.
Name Type Description
element0 any The element(s) to add to the end of the array.
element1 any The element(s) to add to the end of the array.
element... any The element(s) to add to the end of the array.
elementN any The element(s) to add to the end of the array.
Returns:
Type Description
int The new length of the list.

pushUnique(comparisonFunction, element0, element1, elementN){int}

D:/DEV_SRC/RxOT/DuAEF/DuESF/tools/build/output/DuESF.jsxinc, line 1273
Adds one or more elements to the end of the list and returns the new length of the list, only if the value is not already in the list
The internal list may be converted to an Array if needed.
Name Type Description
comparisonFunction function optional A function which compares two values which returns true if the values are considered the same.
element0 any The element(s) to add to the end of the array.
element1 any The element(s) to add to the end of the array.
element... any The element(s) to add to the end of the array.
elementN any The element(s) to add to the end of the array.
Returns:
Type Description
int The new length of the list.

reinitIterator()

D:/DEV_SRC/RxOT/DuAEF/DuESF/tools/build/output/DuESF.jsxinc, line 1423
Reinits the iterator, i.e. go to index -1 so that the next call to DuList.next returns the first item.

remove(index)

D:/DEV_SRC/RxOT/DuAEF/DuESF/tools/build/output/DuESF.jsxinc, line 1163
Removes the item at the given index. The internal list may be converted to an Array if needed.
The iterator invalidated.
Name Type Description
index int The index.

removeAll(index, comparisonFunction){int}

D:/DEV_SRC/RxOT/DuAEF/DuESF/tools/build/output/DuESF.jsxinc, line 1200
Removes all occurences of the value from the list. The value must be checkable with the == operator if no comparisonFunction is provided.
The internal list may be converted to an Array if needed.
The iterator invalidated.
Name Type Description
index int The index.
comparisonFunction function optional A function which compares two values which returns true if the values are considered the same.
Returns:
Type Description
int The number of items removed.

removeDuplicates(comparisonFunction){Array}

D:/DEV_SRC/RxOT/DuAEF/DuESF/tools/build/output/DuESF.jsxinc, line 1017
Removes all duplicated values from the list, and returns them.
The internal list may be converted to an Array if needed.
The iterator invalidated.
Name Type Description
comparisonFunction function optional A function which compares two values which returns true if the values are considered the same.
Returns:
Type Description
Array The duplicated (and removed) values. An empty list for Ae Collections as they can't have duplicated items.

removeOne(index, comparisonFunction)

D:/DEV_SRC/RxOT/DuAEF/DuESF/tools/build/output/DuESF.jsxinc, line 1180
Removes the first value from the list. The value must be checkable with the == operator if no comparisonFunction is provided.
The internal list may be converted to an Array if needed.
The iterator invalidated.
Name Type Description
index int The index.
comparisonFunction function optional A function which compares two values which returns true if the values are considered the same.

replace(what, with, comparisonFunction){int}

D:/DEV_SRC/RxOT/DuAEF/DuESF/tools/build/output/DuESF.jsxinc, line 1393
Replaces all occurences of a value with another value.
The internal list may be converted to an Array if needed.
Name Type Description
what any The current value
with any The new value
comparisonFunction function optional A function which compares two values which returns true if the values are considered the same.
Returns:
Type Description
int The number of occurences which were updated.

sort(compareFunction){Array}

D:/DEV_SRC/RxOT/DuAEF/DuESF/tools/build/output/DuESF.jsxinc, line 1228
Reimplements the Array.sort() method.
The internal list may be converted to an Array if needed.
The iterator invalidated.
Name Type Description
compareFunction function Specifies a function that defines the sort order. If omitted, the array elements are converted to strings, then sorted according to each character's Unicode code point value.
Returns:
Type Description
Array The sorted array. Note that the array is sorted in place, and no copy is made.