mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-04 00:57:48 +00:00
Bump to v3.8.0.
This commit is contained in:
@@ -10,7 +10,6 @@ define(['../internal/assignWith', '../internal/baseAssign', '../internal/createA
|
||||
* **Note:** This method mutates `object` and is based on
|
||||
* [`Object.assign`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.assign).
|
||||
*
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @alias extend
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
define(['../internal/isLength', '../lang/isNative', '../lang/isObject', '../internal/shimKeys'], function(isLength, isNative, isObject, shimKeys) {
|
||||
define(['../internal/isArrayLike', '../lang/isNative', '../lang/isObject', '../internal/shimKeys'], function(isArrayLike, isNative, isObject, shimKeys) {
|
||||
|
||||
/* Native method references for those with the same name as other `lodash` methods. */
|
||||
var nativeKeys = isNative(nativeKeys = Object.keys) && nativeKeys;
|
||||
@@ -31,12 +31,9 @@ define(['../internal/isLength', '../lang/isNative', '../lang/isObject', '../inte
|
||||
* // => ['0', '1']
|
||||
*/
|
||||
var keys = !nativeKeys ? shimKeys : function(object) {
|
||||
if (object) {
|
||||
var Ctor = object.constructor,
|
||||
length = object.length;
|
||||
}
|
||||
var Ctor = object != null && object.constructor;
|
||||
if ((typeof Ctor == 'function' && Ctor.prototype === object) ||
|
||||
(typeof object != 'function' && isLength(length))) {
|
||||
(typeof object != 'function' && isArrayLike(object))) {
|
||||
return shimKeys(object);
|
||||
}
|
||||
return isObject(object) ? nativeKeys(object) : [];
|
||||
|
||||
26
object/mapKeys.js
Normal file
26
object/mapKeys.js
Normal file
@@ -0,0 +1,26 @@
|
||||
define(['../internal/createObjectMapper'], function(createObjectMapper) {
|
||||
|
||||
/**
|
||||
* The opposite of `_.mapValues`; this method creates an object with the
|
||||
* same values as `object` and keys generated by running each own enumerable
|
||||
* property of `object` through `iteratee`.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @category Object
|
||||
* @param {Object} object The object to iterate over.
|
||||
* @param {Function|Object|string} [iteratee=_.identity] The function invoked
|
||||
* per iteration.
|
||||
* @param {*} [thisArg] The `this` binding of `iteratee`.
|
||||
* @returns {Object} Returns the new mapped object.
|
||||
* @example
|
||||
*
|
||||
* _.mapKeys({ 'a': 1, 'b': 2 }, function(value, key) {
|
||||
* return key + value;
|
||||
* });
|
||||
* // => { 'a1': 1, 'b2': 2 }
|
||||
*/
|
||||
var mapKeys = createObjectMapper(true);
|
||||
|
||||
return mapKeys;
|
||||
});
|
||||
@@ -1,4 +1,4 @@
|
||||
define(['../internal/baseCallback', '../internal/baseForOwn'], function(baseCallback, baseForOwn) {
|
||||
define(['../internal/createObjectMapper'], function(createObjectMapper) {
|
||||
|
||||
/**
|
||||
* Creates an object with the same keys as `object` and values generated by
|
||||
@@ -41,15 +41,7 @@ define(['../internal/baseCallback', '../internal/baseForOwn'], function(baseCall
|
||||
* _.mapValues(users, 'age');
|
||||
* // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
|
||||
*/
|
||||
function mapValues(object, iteratee, thisArg) {
|
||||
var result = {};
|
||||
iteratee = baseCallback(iteratee, thisArg, 3);
|
||||
|
||||
baseForOwn(object, function(value, key, object) {
|
||||
result[key] = iteratee(value, key, object);
|
||||
});
|
||||
return result;
|
||||
}
|
||||
var mapValues = createObjectMapper();
|
||||
|
||||
return mapValues;
|
||||
});
|
||||
|
||||
@@ -3,11 +3,6 @@ define(['../internal/arrayMap', '../internal/baseDifference', '../internal/baseF
|
||||
/**
|
||||
* The opposite of `_.pick`; this method creates an object composed of the
|
||||
* own and inherited enumerable properties of `object` that are not omitted.
|
||||
* Property names may be specified as individual arguments or as arrays of
|
||||
* property names. If `predicate` is provided it is invoked for each property
|
||||
* of `object` omitting the properties `predicate` returns truthy for. The
|
||||
* predicate is bound to `thisArg` and invoked with three arguments:
|
||||
* (value, key, object).
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
|
||||
Reference in New Issue
Block a user