mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-04 17:07:49 +00:00
Update vendors, builds, and docs.
Former-commit-id: 8e6ca9a1334c73671aba1b4c974d738dbd7d72e1
This commit is contained in:
@@ -715,6 +715,23 @@
|
||||
return result
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates an array composed of the own enumerable property names of `object`.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @category Objects
|
||||
* @param {Object} object The object to inspect.
|
||||
* @returns {Array} Returns a new array of property names.
|
||||
* @example
|
||||
*
|
||||
* _.keys({ 'one': 1, 'two': 2, 'three': 3 });
|
||||
* // => ['one', 'two', 'three'] (order is not guaranteed)
|
||||
*/
|
||||
var keys = !nativeKeys ? shimKeys : function(object) {
|
||||
return (isObject(object) ? nativeKeys(object) : []);
|
||||
};
|
||||
|
||||
/**
|
||||
* A fallback implementation of `isPlainObject` that checks if a given `value`
|
||||
* is an object created by the `Object` constructor, assuming objects created
|
||||
@@ -912,10 +929,15 @@
|
||||
* // => { 'Moe': 'first', 'Larry': 'second', 'Curly': 'third' } (order is not guaranteed)
|
||||
*/
|
||||
function invert(object) {
|
||||
var result = {};
|
||||
forOwn(object, function(value, key) {
|
||||
result[value] = key;
|
||||
});
|
||||
var index = -1,
|
||||
props = keys(object),
|
||||
length = props.length,
|
||||
result = {};
|
||||
|
||||
while (++index < length) {
|
||||
var key = props[index];
|
||||
result[object[key]] = key;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1371,23 +1393,6 @@
|
||||
return typeof value == 'undefined';
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an array composed of the own enumerable property names of `object`.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @category Objects
|
||||
* @param {Object} object The object to inspect.
|
||||
* @returns {Array} Returns a new array of property names.
|
||||
* @example
|
||||
*
|
||||
* _.keys({ 'one': 1, 'two': 2, 'three': 3 });
|
||||
* // => ['one', 'two', 'three'] (order is not guaranteed)
|
||||
*/
|
||||
var keys = !nativeKeys ? shimKeys : function(object) {
|
||||
return (isObject(object) ? nativeKeys(object) : []);
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates a shallow clone of `object` excluding the specified properties.
|
||||
* Property names may be specified as individual arguments or as arrays of
|
||||
@@ -1440,10 +1445,15 @@
|
||||
* // => [['moe', 30], ['larry', 40], ['curly', 50]] (order is not guaranteed)
|
||||
*/
|
||||
function pairs(object) {
|
||||
var result = [];
|
||||
forOwn(object, function(value, key) {
|
||||
result.push([key, value]);
|
||||
});
|
||||
var index = -1,
|
||||
props = keys(object),
|
||||
length = props.length,
|
||||
result = Array(length);
|
||||
|
||||
while (++index < length) {
|
||||
var key = props[index];
|
||||
result[index] = [key, object[key]];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1501,10 +1511,14 @@
|
||||
* // => [1, 2, 3]
|
||||
*/
|
||||
function values(object) {
|
||||
var result = [];
|
||||
forOwn(object, function(value) {
|
||||
result.push(value);
|
||||
});
|
||||
var index = -1,
|
||||
props = keys(object),
|
||||
length = props.length,
|
||||
result = Array(length);
|
||||
|
||||
while (++index < length) {
|
||||
result[index] = object[props[index]];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user