mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-03 08:37:49 +00:00
Add _.invert and _.pairs.
Former-commit-id: b265ed3f148e5e951b8d061107bb376e0b2e651e
This commit is contained in:
24
lodash.js
24
lodash.js
@@ -1286,6 +1286,26 @@
|
||||
return object ? hasOwnProperty.call(object, property) : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Invert the keys and values of an object. The values must be serializable.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @alias methods
|
||||
* @category Objects
|
||||
* @param {Object} object The object to inspect.
|
||||
* @returns {Array} Returns a new array of property names that have function values.
|
||||
* @example
|
||||
*
|
||||
* var obj = {first: 'Moe', second: 'Larry', third: 'Curly'}
|
||||
* // => ['all', 'any', 'bind', 'bindAll', 'clone', 'compact', 'compose', ...]
|
||||
*/
|
||||
var invert = createIterator({
|
||||
'args': 'object',
|
||||
'init': '{}',
|
||||
'inLoop': 'result[value] = index'
|
||||
});
|
||||
|
||||
/**
|
||||
* Checks if `value` is a boolean (`true` or `false`) value.
|
||||
*
|
||||
@@ -1878,7 +1898,7 @@
|
||||
* });
|
||||
* // => { 'name': 'moe' }
|
||||
*/
|
||||
var pick = createIterator(dropIteratorOptions, {
|
||||
var pick = createIterator(omitIteratorOptions, {
|
||||
'top':
|
||||
'if (typeof callback != \'function\') {\n' +
|
||||
' var prop,\n' +
|
||||
@@ -4226,6 +4246,7 @@
|
||||
lodash.indexOf = indexOf;
|
||||
lodash.initial = initial;
|
||||
lodash.intersection = intersection;
|
||||
lodash.invert = invert;
|
||||
lodash.invoke = invoke;
|
||||
lodash.isArguments = isArguments;
|
||||
lodash.isArray = isArray;
|
||||
@@ -4256,6 +4277,7 @@
|
||||
lodash.object = object;
|
||||
lodash.omit = omit;
|
||||
lodash.once = once;
|
||||
lodash.pairs = pairs;
|
||||
lodash.partial = partial;
|
||||
lodash.pick = pick;
|
||||
lodash.pluck = pluck;
|
||||
|
||||
Reference in New Issue
Block a user