mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-01 07:47:49 +00:00
Bump to v3.8.0.
This commit is contained in:
@@ -12,7 +12,6 @@ import createAssigner from '../internal/createAssigner';
|
||||
* **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 @@
|
||||
import isLength from '../internal/isLength';
|
||||
import isArrayLike from '../internal/isArrayLike';
|
||||
import isNative from '../lang/isNative';
|
||||
import isObject from '../lang/isObject';
|
||||
import shimKeys from '../internal/shimKeys';
|
||||
@@ -34,12 +34,9 @@ var nativeKeys = isNative(nativeKeys = Object.keys) && nativeKeys;
|
||||
* // => ['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) : [];
|
||||
|
||||
25
object/mapKeys.js
Normal file
25
object/mapKeys.js
Normal file
@@ -0,0 +1,25 @@
|
||||
import createObjectMapper from '../internal/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);
|
||||
|
||||
export default mapKeys;
|
||||
@@ -1,5 +1,4 @@
|
||||
import baseCallback from '../internal/baseCallback';
|
||||
import baseForOwn from '../internal/baseForOwn';
|
||||
import createObjectMapper from '../internal/createObjectMapper';
|
||||
|
||||
/**
|
||||
* Creates an object with the same keys as `object` and values generated by
|
||||
@@ -42,14 +41,6 @@ import baseForOwn from '../internal/baseForOwn';
|
||||
* _.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();
|
||||
|
||||
export default mapValues;
|
||||
|
||||
@@ -10,11 +10,6 @@ import restParam from '../function/restParam';
|
||||
/**
|
||||
* 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