mirror of
https://github.com/swc-project/swc.git
synced 2024-12-22 13:11:31 +03:00
33 lines
876 B
TypeScript
33 lines
876 B
TypeScript
|
// Loaded from https://deno.land/x/ramda@v0.27.2/source/fromPairs.js
|
||
|
|
||
|
|
||
|
import _curry1 from './internal/_curry1.js';
|
||
|
|
||
|
|
||
|
/**
|
||
|
* Creates a new object from a list key-value pairs. If a key appears in
|
||
|
* multiple pairs, the rightmost pair is included in the object.
|
||
|
*
|
||
|
* @func
|
||
|
* @memberOf R
|
||
|
* @since v0.3.0
|
||
|
* @category List
|
||
|
* @sig [[k,v]] -> {k: v}
|
||
|
* @param {Array} pairs An array of two-element arrays that will be the keys and values of the output object.
|
||
|
* @return {Object} The object made by pairing up `keys` and `values`.
|
||
|
* @see R.toPairs, R.pair
|
||
|
* @example
|
||
|
*
|
||
|
* R.fromPairs([['a', 1], ['b', 2], ['c', 3]]); //=> {a: 1, b: 2, c: 3}
|
||
|
*/
|
||
|
var fromPairs = _curry1(function fromPairs(pairs) {
|
||
|
var result = {};
|
||
|
var idx = 0;
|
||
|
while (idx < pairs.length) {
|
||
|
result[pairs[idx][0]] = pairs[idx][1];
|
||
|
idx += 1;
|
||
|
}
|
||
|
return result;
|
||
|
});
|
||
|
export default fromPairs;
|