source: node_modules/ramda/es/mapObjIndexed.js

main
Last change on this file was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago

Initial commit

  • Property mode set to 100644
File size: 967 bytes
Line 
1import _arrayReduce from "./internal/_arrayReduce.js";
2import _curry2 from "./internal/_curry2.js";
3import keys from "./keys.js";
4/**
5 * An Object-specific version of [`map`](#map). The function is applied to three
6 * arguments: *(value, key, obj)*. If only the value is significant, use
7 * [`map`](#map) instead.
8 *
9 * @func
10 * @memberOf R
11 * @since v0.9.0
12 * @category Object
13 * @sig ((*, String, Object) -> *) -> Object -> Object
14 * @param {Function} fn
15 * @param {Object} obj
16 * @return {Object}
17 * @see R.map
18 * @example
19 *
20 * const xyz = { x: 1, y: 2, z: 3 };
21 * const prependKeyAndDouble = (num, key, obj) => key + (num * 2);
22 *
23 * R.mapObjIndexed(prependKeyAndDouble, xyz); //=> { x: 'x2', y: 'y4', z: 'z6' }
24 */
25
26var mapObjIndexed =
27/*#__PURE__*/
28_curry2(function mapObjIndexed(fn, obj) {
29 return _arrayReduce(function (acc, key) {
30 acc[key] = fn(obj[key], key, obj);
31 return acc;
32 }, {}, keys(obj));
33});
34
35export default mapObjIndexed;
Note: See TracBrowser for help on using the repository browser.