source: node_modules/ramda-adjunct/lib/zipObjWith.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.3 KB
RevLine 
[d24f17c]1"use strict";
2
3exports.__esModule = true;
4exports["default"] = void 0;
5var _ramda = require("ramda");
6/**
7 * Creates a new object out of a list of keys and a list of values by applying the function
8 * to each equally-positioned pair in the lists.
9 * Key/value pairing is truncated to the length of the shorter of the two lists.
10 *
11 * @func zipObjWith
12 * @memberOf RA
13 * @category Object
14 * @since {@link https://char0n.github.io/ramda-adjunct/2.22.0|v2.22.0}
15 * @sig (b, a) -> [k, v] -> [a] -> [b] -> { k: v }
16 * @param {Function} fn The function to transform each value-key pair
17 * @param {Array} keys Array to transform into the properties on the output object
18 * @param {Array} values Array to transform into the values on the output object
19 * @return {Object} The object made by pairing up and transforming same-indexed elements of `keys` and `values`.
20 * @see {@link https://ramdajs.com/docs/#zipObj|zipObj}, {@link RA.unzipObjWith|unzipObjWith}
21 * @example
22 *
23 * RA.zipObjWith((value, key) => [key, `${key}${value + 1}`]), ['a', 'b', 'c'], [1, 2, 3]);
24 * // => { a: 'a2', b: 'b3', c: 'c4' }
25 */
26var zipObjWith = (0, _ramda.curryN)(3, function (fn, keys, values) {
27 return (0, _ramda.pipe)(_ramda.zip, (0, _ramda.map)((0, _ramda.apply)(fn)), _ramda.fromPairs)(values, keys);
28});
29var _default = zipObjWith;
30exports["default"] = _default;
Note: See TracBrowser for help on using the repository browser.