1 | var _curry2 =
|
2 | /*#__PURE__*/
|
3 | require("./internal/_curry2");
|
4 |
|
5 | var keys =
|
6 | /*#__PURE__*/
|
7 | require("./keys");
|
8 | /**
|
9 | * Iterate over an input `object`, calling a provided function `fn` for each
|
10 | * key and value in the object.
|
11 | *
|
12 | * `fn` receives three argument: *(value, key, obj)*.
|
13 | *
|
14 | * @func
|
15 | * @memberOf R
|
16 | * @since v0.23.0
|
17 | * @category Object
|
18 | * @sig ((a, String, StrMap a) -> Any) -> StrMap a -> StrMap a
|
19 | * @param {Function} fn The function to invoke. Receives three argument, `value`, `key`, `obj`.
|
20 | * @param {Object} obj The object to iterate over.
|
21 | * @return {Object} The original object.
|
22 | * @example
|
23 | *
|
24 | * const printKeyConcatValue = (value, key) => console.log(key + ':' + value);
|
25 | * R.forEachObjIndexed(printKeyConcatValue, {x: 1, y: 2}); //=> {x: 1, y: 2}
|
26 | * // logs x:1
|
27 | * // logs y:2
|
28 | * @symb R.forEachObjIndexed(f, {x: a, y: b}) = {x: a, y: b}
|
29 | */
|
30 |
|
31 |
|
32 | var forEachObjIndexed =
|
33 | /*#__PURE__*/
|
34 | _curry2(function forEachObjIndexed(fn, obj) {
|
35 | var keyList = keys(obj);
|
36 | var idx = 0;
|
37 |
|
38 | while (idx < keyList.length) {
|
39 | var key = keyList[idx];
|
40 | fn(obj[key], key, obj);
|
41 | idx += 1;
|
42 | }
|
43 |
|
44 | return obj;
|
45 | });
|
46 |
|
47 | module.exports = forEachObjIndexed; |
\ | No newline at end of file |