1 | var _curry2 =
|
2 | /*#__PURE__*/
|
3 | require("./internal/_curry2");
|
4 |
|
5 | var _reduce =
|
6 | /*#__PURE__*/
|
7 | require("./internal/_reduce");
|
8 |
|
9 | var keys =
|
10 | /*#__PURE__*/
|
11 | require("./keys");
|
12 | /**
|
13 | * An Object-specific version of [`map`](#map). The function is applied to three
|
14 | * arguments: *(value, key, obj)*. If only the value is significant, use
|
15 | * [`map`](#map) instead.
|
16 | *
|
17 | * @func
|
18 | * @memberOf R
|
19 | * @since v0.9.0
|
20 | * @category Object
|
21 | * @sig ((*, String, Object) -> *) -> Object -> Object
|
22 | * @param {Function} fn
|
23 | * @param {Object} obj
|
24 | * @return {Object}
|
25 | * @see R.map
|
26 | * @example
|
27 | *
|
28 | * const xyz = { x: 1, y: 2, z: 3 };
|
29 | * const prependKeyAndDouble = (num, key, obj) => key + (num * 2);
|
30 | *
|
31 | * R.mapObjIndexed(prependKeyAndDouble, xyz); //=> { x: 'x2', y: 'y4', z: 'z6' }
|
32 | */
|
33 |
|
34 |
|
35 | var mapObjIndexed =
|
36 | /*#__PURE__*/
|
37 | _curry2(function mapObjIndexed(fn, obj) {
|
38 | return _reduce(function (acc, key) {
|
39 | acc[key] = fn(obj[key], key, obj);
|
40 | return acc;
|
41 | }, {}, keys(obj));
|
42 | });
|
43 |
|
44 | module.exports = mapObjIndexed; |
\ | No newline at end of file |