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:
820 bytes
|
Rev | Line | |
---|
[d24f17c] | 1 | import _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 |
|
---|
| 19 | var 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 |
|
---|
| 33 | export default fromPairs; |
---|
Note:
See
TracBrowser
for help on using the repository browser.