mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-14 20:57:49 +00:00
Bump to v4.0.0.
This commit is contained in:
37
lodash.frompairs/index.js
Normal file
37
lodash.frompairs/index.js
Normal file
@@ -0,0 +1,37 @@
|
||||
/**
|
||||
* lodash 4.0.0 (Custom Build) <https://lodash.com/>
|
||||
* Build: `lodash modularize exports="npm" -o ./`
|
||||
* Copyright 2012-2016 The Dojo Foundation <http://dojofoundation.org/>
|
||||
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
|
||||
* Copyright 2009-2016 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
||||
* Available under MIT license <https://lodash.com/license>
|
||||
*/
|
||||
var baseSet = require('lodash._baseset');
|
||||
|
||||
/**
|
||||
* The inverse of `_.toPairs`; this method returns an object composed
|
||||
* from key-value `pairs`.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @category Array
|
||||
* @param {Array} pairs The key-value pairs.
|
||||
* @returns {Object} Returns the new object.
|
||||
* @example
|
||||
*
|
||||
* _.fromPairs([['fred', 30], ['barney', 40]]);
|
||||
* // => { 'fred': 30, 'barney': 40 }
|
||||
*/
|
||||
function fromPairs(pairs) {
|
||||
var index = -1,
|
||||
length = pairs ? pairs.length : 0,
|
||||
result = {};
|
||||
|
||||
while (++index < length) {
|
||||
var pair = pairs[index];
|
||||
baseSet(result, pair[0], pair[1]);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
module.exports = fromPairs;
|
||||
Reference in New Issue
Block a user