Urara-Blog/node_modules/.pnpm-store/v3/files/4f/9c9c0fe6d5674cbbb4ced4a1c7612b883e60cfb2ee2e83189c6f5af77da817293ce36ab542b945ef6869e4af5763cb2dee92d9c654072c137849b22b301f0a
2022-08-14 01:14:53 +08:00

28 lines
596 B
Text

/**
* The inverse of `_.toPairs`; this method returns an object composed
* from key-value `pairs`.
*
* @static
* @memberOf _
* @since 4.0.0
* @category Array
* @param {Array} pairs The key-value pairs.
* @returns {Object} Returns the new object.
* @example
*
* _.fromPairs([['a', 1], ['b', 2]]);
* // => { 'a': 1, 'b': 2 }
*/
function fromPairs(pairs) {
var index = -1,
length = pairs == null ? 0 : pairs.length,
result = {};
while (++index < length) {
var pair = pairs[index];
result[pair[0]] = pair[1];
}
return result;
}
module.exports = fromPairs;