NodeList~extras2 Class
Augments Y.NodeList with the same higher-order functions that array-extras adds to Y.Array.
Methods
every
-
f
-
c
Executes the supplied function on each Node in the NodeList. Iteration stops if the supplied function does not return a truthy value. The function receives the Node, the index, and the NodeList itself as parameters (in that order).
Parameters:
-
f
Functionthe function to execute on each item
-
c
Objectoptional context object
Returns:
find
-
f
-
c
Executes the supplied function on each Node in the NodeList, searching for the first Node that matches the supplied function. The function receives the Node, the index, and the NodeList itself as parameters (in that order).
Parameters:
-
f
Functionthe function to execute on each item
-
c
Objectoptional context object
Returns:
map
-
f
-
c
Executes the supplied function on each Node in the NodeList and returns a new array with the results. The function receives the Node, the index, and the NodeList itself as parameters (in that order).
Parameters:
-
f
Stringthe function to invoke
-
c
Objectoptional context object
Returns:
partition
-
f
-
c
Partitions the NodeList into two new NodeLists, one with the items for which the supplied function returns true, and one with the items for which the function returns false. The function receives the Node, the index, and the NodeList itself as parameters (in that order).
Parameters:
-
f
Functionthe function to execute on each item
-
c
Objectoptional context object
Returns:
reduce
-
init
-
f
-
c
Executes the supplied function on each Node in the NodeList, folding the NodeList into a single value. The function receives the value returned by the previous iteration (or the initial value if this is the first iteration), the Node being iterated, the index, and the NodeList itself as parameters (in that order). The function must return the updated value.
Parameters:
-
init
Mixedthe initial value
-
f
Stringthe function to invoke
-
c
Objectoptional context object
Returns:
reduceRight
-
init
-
f
-
c
Executes the supplied function on each Node in the NodeList, starting at the end and folding the NodeList into a single value. The function receives the value returned by the previous iteration (or the initial value if this is the first iteration), the Node being iterated, the index, and the NodeList itself as parameters (in that order). The function must return the updated value.
Parameters:
-
init
Mixedthe initial value
-
f
Stringthe function to invoke
-
c
Objectoptional context object