time-to-botec/squiggle/node_modules/@stdlib/utils/key-by-right/docs/repl.txt
NunoSempere b6addc7f05 feat: add the node modules
Necessary in order to clearly see the squiggle hotwiring.
2022-12-03 12:44:49 +00:00

44 lines
1.1 KiB
Plaintext

{{alias}}( collection, fcn[, thisArg] )
Converts a collection to an object whose keys are determined by a provided
function and whose values are the collection values, iterating from right to
left.
When invoked, the input function is provided two arguments:
- `value`: collection value
- `index`: collection index
If more than one element in a collection resolves to the same key, the key
value is the collection element which last resolved to the key.
Object values are shallow copies.
Parameters
----------
collection: Array|TypedArray|Object
Input collection over which to iterate. If provided an object, the
object must be array-like (excluding strings and functions).
fcn: Function
The function to invoke for each element in a collection.
thisArg: any (optional)
Execution context.
Returns
-------
out: Object
Output object.
Examples
--------
> function toKey( v ) { return v.a; };
> var arr = [ { 'a': 1 }, { 'a': 2 } ];
> {{alias}}( arr, toKey )
{ '2': { 'a': 2 }, '1': { 'a': 1 } }
See Also
--------