mirror of
https://github.com/swc-project/swc.git
synced 2024-12-26 07:02:28 +03:00
35 lines
1007 B
TypeScript
35 lines
1007 B
TypeScript
// Loaded from https://deno.land/x/ramda@v0.27.2/source/zipObj.js
|
|
|
|
|
|
import _curry2 from './internal/_curry2.js';
|
|
|
|
|
|
/**
|
|
* Creates a new object out of a list of keys and a list of values.
|
|
* Key/value pairing is truncated to the length of the shorter of the two lists.
|
|
* Note: `zipObj` is equivalent to `pipe(zip, fromPairs)`.
|
|
*
|
|
* @func
|
|
* @memberOf R
|
|
* @since v0.3.0
|
|
* @category List
|
|
* @sig [String] -> [*] -> {String: *}
|
|
* @param {Array} keys The array that will be properties on the output object.
|
|
* @param {Array} values The list of values on the output object.
|
|
* @return {Object} The object made by pairing up same-indexed elements of `keys` and `values`.
|
|
* @example
|
|
*
|
|
* R.zipObj(['a', 'b', 'c'], [1, 2, 3]); //=> {a: 1, b: 2, c: 3}
|
|
*/
|
|
var zipObj = _curry2(function zipObj(keys, values) {
|
|
var idx = 0;
|
|
var len = Math.min(keys.length, values.length);
|
|
var out = {};
|
|
while (idx < len) {
|
|
out[keys[idx]] = values[idx];
|
|
idx += 1;
|
|
}
|
|
return out;
|
|
});
|
|
export default zipObj;
|