source: node_modules/ramda/es/zipObj.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: 954 bytes
Line 
1import _curry2 from "./internal/_curry2.js";
2/**
3 * Creates a new object out of a list of keys and a list of values.
4 * Key/value pairing is truncated to the length of the shorter of the two lists.
5 * Note: `zipObj` is equivalent to `pipe(zip, fromPairs)`.
6 *
7 * @func
8 * @memberOf R
9 * @since v0.3.0
10 * @category List
11 * @sig [String] -> [*] -> {String: *}
12 * @param {Array} keys The array that will be properties on the output object.
13 * @param {Array} values The list of values on the output object.
14 * @return {Object} The object made by pairing up same-indexed elements of `keys` and `values`.
15 * @example
16 *
17 * R.zipObj(['a', 'b', 'c'], [1, 2, 3]); //=> {a: 1, b: 2, c: 3}
18 */
19
20var zipObj =
21/*#__PURE__*/
22_curry2(function zipObj(keys, values) {
23 var idx = 0;
24 var len = Math.min(keys.length, values.length);
25 var out = {};
26
27 while (idx < len) {
28 out[keys[idx]] = values[idx];
29 idx += 1;
30 }
31
32 return out;
33});
34
35export default zipObj;
Note: See TracBrowser for help on using the repository browser.