source: node_modules/ramda/es/forEachObjIndexed.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: 1.1 KB
Line 
1import _curry2 from "./internal/_curry2.js";
2import keys from "./keys.js";
3/**
4 * Iterate over an input `object`, calling a provided function `fn` for each
5 * key and value in the object.
6 *
7 * `fn` receives three argument: *(value, key, obj)*.
8 *
9 * @func
10 * @memberOf R
11 * @since v0.23.0
12 * @category Object
13 * @sig ((a, String, StrMap a) -> Any) -> StrMap a -> StrMap a
14 * @param {Function} fn The function to invoke. Receives three argument, `value`, `key`, `obj`.
15 * @param {Object} obj The object to iterate over.
16 * @return {Object} The original object.
17 * @example
18 *
19 * const printKeyConcatValue = (value, key) => console.log(key + ':' + value);
20 * R.forEachObjIndexed(printKeyConcatValue, {x: 1, y: 2}); //=> {x: 1, y: 2}
21 * // logs x:1
22 * // logs y:2
23 * @symb R.forEachObjIndexed(f, {x: a, y: b}) = {x: a, y: b}
24 */
25
26var forEachObjIndexed =
27/*#__PURE__*/
28_curry2(function forEachObjIndexed(fn, obj) {
29 var keyList = keys(obj);
30 var idx = 0;
31
32 while (idx < keyList.length) {
33 var key = keyList[idx];
34 fn(obj[key], key, obj);
35 idx += 1;
36 }
37
38 return obj;
39});
40
41export default forEachObjIndexed;
Note: See TracBrowser for help on using the repository browser.