map-assoc-core
Just the very basics of map-assoc: Map the values of a collection (array or object) and carry the keys.
For more magic, check the map-assoc-fancy
package.
Promises support
No. Use p-props
instead.
Usage
from test/usage.js:
var amap = eq = preset; { return Strings; } { return s === +s ? s * 2 : s; } ; preset = ;; ;;; ;;
Q&A
- How is this different from
lodash.mapValues
?
It supports presets (see usage example above). It preserves the array-ness or null-object-ness of inputs (see test/cmp.lodash.js).
- My string/buffer is a collection, too! It maps position numbers to characters/octets!
You're totally right, and map-assoc-fancy
will handle that just as you'd
expect, i.e. map them to a String/Buffer.
The …-core
package (this one) will return plain objects with number keys.
(Exception: The empty string is returned verbatim.)
- Can I use my GeneratorFunction as a collection?
Should work, since it should be an object, so it can hold keys, right?
If you want to iterate over its results instead,
have a look at map-assoc-fancy
.
(:TODO: publish that, and write the actual function name here.)
License
ISC