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