UNPKG

837 BJavaScriptView Raw
1var _curry1 =
2/*#__PURE__*/
3require("./internal/_curry1");
4/**
5 * Creates a new object from a list key-value pairs. If a key appears in
6 * multiple pairs, the rightmost pair is included in the object.
7 *
8 * @func
9 * @memberOf R
10 * @since v0.3.0
11 * @category List
12 * @sig [[k,v]] -> {k: v}
13 * @param {Array} pairs An array of two-element arrays that will be the keys and values of the output object.
14 * @return {Object} The object made by pairing up `keys` and `values`.
15 * @see R.toPairs, R.pair
16 * @example
17 *
18 * R.fromPairs([['a', 1], ['b', 2], ['c', 3]]); //=> {a: 1, b: 2, c: 3}
19 */
20
21
22var fromPairs =
23/*#__PURE__*/
24_curry1(function fromPairs(pairs) {
25 var result = {};
26 var idx = 0;
27
28 while (idx < pairs.length) {
29 result[pairs[idx][0]] = pairs[idx][1];
30 idx += 1;
31 }
32
33 return result;
34});
35
36module.exports = fromPairs;
\No newline at end of file