action-debian-package/node_modules/ramda/es/zipObj.js
Dawid Dziurla 9308795b8b
update
2020-03-26 15:37:35 +01:00

35 lines
954 B
JavaScript

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 =
/*#__PURE__*/
_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;