Object~extras Class
Augments Y.Object with the same higher-order functions that array-extras adds to Y.Array. Note that, unlike Y.Array, iteration order for objects is arbitrary, so be careful when applying non-commutative operations!
Item Index
Methods
every
-
o
-
f
-
c
-
proto
Executes the supplied function on each item in the object. Iteration stops if the supplied function does not return a truthy value. The function receives the value, the key, and the object itself as parameters (in that order).
By default, only properties owned by obj are enumerated. To include prototype properties, set the proto parameter to true.
Parameters:
-
o
Objectthe object to iterate
-
f
Functionthe function to execute on each item
-
c
Objectoptional context object
-
proto
Booleaninclude prototype properties
Returns:
filter
-
o
-
f
-
c
-
proto
Executes the supplied function on each item in the object. Returns a new object containing the items for which the supplied function returned a truthy value. The function receives the value, the key, and the object itself as parameters (in that order).
By default, only properties owned by obj are enumerated. To include prototype properties, set the proto parameter to true.
Parameters:
-
o
Objectthe object to iterate
-
f
Functionthe function to execute on each item
-
c
Objectoptional context object
-
proto
Booleaninclude prototype properties
Returns:
find
-
o
-
f
-
c
-
proto
Executes the supplied function on each item in the object, searching for the first item that matches the supplied function. The function receives the value, the key, and the object itself as parameters (in that order).
By default, only properties owned by obj are enumerated. To include prototype properties, set the proto parameter to true.
Parameters:
-
o
Objectthe object to iterate
-
f
Functionthe function to execute on each item
-
c
Objectoptional context object
-
proto
Booleaninclude prototype properties
Returns:
invoke
-
o
-
f
-
args
Executes a named method on each item in the object. Items that do not have a function by that name will be skipped.
Parameters:
-
o
Objectthe object to iterate
-
f
Stringthe function to invoke
-
args
Any multipleany number of additional args are passed as parameters to the execution of the named method
Returns:
keyOf
-
o
-
v
-
proto
Executes the supplied function on each item in the object, searching for the first item that matches the supplied function.
By default, only properties owned by obj are enumerated. To include prototype properties, set the proto parameter to true.
Parameters:
-
o
Objectthe object to iterate
-
v
Mixedthe value to search for
-
proto
Booleaninclude prototype properties
Returns:
map
-
o
-
f
-
c
-
proto
Executes the supplied function on each item in the object and returns a new object with the results. The function receives the value, the key, and the object itself as parameters (in that order).
By default, only properties owned by obj are enumerated. To include prototype properties, set the proto parameter to true.
Parameters:
-
o
Objectthe object to iterate
-
f
Stringthe function to invoke
-
c
Objectoptional context object
-
proto
Booleaninclude prototype properties
Returns:
partition
-
o
-
f
-
c
-
proto
Partitions an object into two new objects, 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 value, the key, and the object itself as parameters (in that order).
By default, only properties owned by obj are enumerated. To include prototype properties, set the proto parameter to true.
Parameters:
-
o
Objectthe object to iterate
-
f
Functionthe function to execute on each item
-
c
Objectoptional context object
-
proto
Booleaninclude prototype properties
Returns:
reduce
-
o
-
init
-
f
-
c
-
proto
Executes the supplied function on each item in the object, folding the object 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 value being iterated, the key, and the object itself as parameters (in that order). The function must return the updated value.
By default, only properties owned by obj are enumerated. To include prototype properties, set the proto parameter to true.
Parameters:
-
o
Objectthe object to iterate
-
init
Mixedthe initial value
-
f
Stringthe function to invoke
-
c
Objectoptional context object
-
proto
Booleaninclude prototype properties
Returns:
reduceRight
-
o
-
init
-
f
-
c
-
proto
Executes the supplied function on each item in the object, starting at the end and folding the object 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 value being iterated, the key, and the object itself as parameters (in that order). The function must return the updated value.
By default, only properties owned by obj are enumerated. To include prototype properties, set the proto parameter to true.
Since the order of iteration is undefined for objects, this is identical
to reduce
.
Parameters:
-
o
Objectthe object to iterate
-
init
Mixedthe initial value
-
f
Stringthe function to invoke
-
c
Objectoptional context object
-
proto
Booleaninclude prototype properties
Returns:
reject
-
o
-
f
-
c
-
proto
Executes the supplied function on each item in the object. Returns a new object containing the items for which the supplied function returned a falsey value. The function receives the value, the key, and the object itself as parameters (in that order).
By default, only properties owned by obj are enumerated. To include prototype properties, set the proto parameter to true.
Parameters:
-
o
Objectthe object to iterate
-
f
Functionthe function to execute on each item
-
c
Objectoptional context object
-
proto
Booleaninclude prototype properties
Returns:
zip
-
a1
-
a2
Creates an object by pairing the corresponding elements of two arrays.
Parameters:
-
a1
Arraythe keys which must be strings
-
a2
Arraythe values