UNPKG

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