mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-01 23:57:49 +00:00
Bump to v3.10.0.
This commit is contained in:
@@ -10,7 +10,7 @@ import createAssigner from '../internal/createAssigner';
|
||||
* (objectValue, sourceValue, key, object, source).
|
||||
*
|
||||
* **Note:** This method mutates `object` and is based on
|
||||
* [`Object.assign`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.assign).
|
||||
* [`Object.assign`](http://ecma-international.org/ecma-262/6.0/#sec-object.assign).
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
|
||||
@@ -39,7 +39,7 @@ import isIterateeCall from '../internal/isIterateeCall';
|
||||
function create(prototype, properties, guard) {
|
||||
var result = baseCreate(prototype);
|
||||
if (guard && isIterateeCall(prototype, properties, guard)) {
|
||||
properties = null;
|
||||
properties = undefined;
|
||||
}
|
||||
return properties ? baseAssign(result, properties) : result;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import assign from './assign';
|
||||
import assignDefaults from '../internal/assignDefaults';
|
||||
import restParam from '../function/restParam';
|
||||
import createDefaults from '../internal/createDefaults';
|
||||
|
||||
/**
|
||||
* Assigns own enumerable properties of source object(s) to the destination
|
||||
@@ -20,13 +20,6 @@ import restParam from '../function/restParam';
|
||||
* _.defaults({ 'user': 'barney' }, { 'age': 36 }, { 'user': 'fred' });
|
||||
* // => { 'user': 'barney', 'age': 36 }
|
||||
*/
|
||||
var defaults = restParam(function(args) {
|
||||
var object = args[0];
|
||||
if (object == null) {
|
||||
return object;
|
||||
}
|
||||
args.push(assignDefaults);
|
||||
return assign.apply(undefined, args);
|
||||
});
|
||||
var defaults = createDefaults(assign, assignDefaults);
|
||||
|
||||
export default defaults;
|
||||
|
||||
25
object/defaultsDeep.js
Normal file
25
object/defaultsDeep.js
Normal file
@@ -0,0 +1,25 @@
|
||||
import createDefaults from '../internal/createDefaults';
|
||||
import merge from './merge';
|
||||
import mergeDefaults from '../internal/mergeDefaults';
|
||||
|
||||
/**
|
||||
* This method is like `_.defaults` except that it recursively assigns
|
||||
* default properties.
|
||||
*
|
||||
* **Note:** This method mutates `object`.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @category Object
|
||||
* @param {Object} object The destination object.
|
||||
* @param {...Object} [sources] The source objects.
|
||||
* @returns {Object} Returns `object`.
|
||||
* @example
|
||||
*
|
||||
* _.defaultsDeep({ 'user': { 'name': 'barney' } }, { 'user': { 'name': 'fred', 'age': 36 } });
|
||||
* // => { 'user': { 'name': 'barney', 'age': 36 } }
|
||||
*
|
||||
*/
|
||||
var defaultsDeep = createDefaults(merge, mergeDefaults);
|
||||
|
||||
export default defaultsDeep;
|
||||
@@ -32,7 +32,7 @@ var hasOwnProperty = objectProto.hasOwnProperty;
|
||||
*/
|
||||
function invert(object, multiValue, guard) {
|
||||
if (guard && isIterateeCall(object, multiValue, guard)) {
|
||||
multiValue = null;
|
||||
multiValue = undefined;
|
||||
}
|
||||
var index = -1,
|
||||
props = keys(object),
|
||||
|
||||
@@ -10,7 +10,7 @@ var nativeKeys = getNative(Object, 'keys');
|
||||
* Creates an array of the own enumerable property names of `object`.
|
||||
*
|
||||
* **Note:** Non-object values are coerced to objects. See the
|
||||
* [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.keys)
|
||||
* [ES spec](http://ecma-international.org/ecma-262/6.0/#sec-object.keys)
|
||||
* for more details.
|
||||
*
|
||||
* @static
|
||||
@@ -34,7 +34,7 @@ var nativeKeys = getNative(Object, 'keys');
|
||||
* // => ['0', '1']
|
||||
*/
|
||||
var keys = !nativeKeys ? shimKeys : function(object) {
|
||||
var Ctor = object == null ? null : object.constructor;
|
||||
var Ctor = object == null ? undefined : object.constructor;
|
||||
if ((typeof Ctor == 'function' && Ctor.prototype === object) ||
|
||||
(typeof object != 'function' && isArrayLike(object))) {
|
||||
return shimKeys(object);
|
||||
|
||||
@@ -46,7 +46,7 @@ function transform(object, iteratee, accumulator, thisArg) {
|
||||
if (isArr) {
|
||||
accumulator = isArray(object) ? new Ctor : [];
|
||||
} else {
|
||||
accumulator = baseCreate(isFunction(Ctor) ? Ctor.prototype : null);
|
||||
accumulator = baseCreate(isFunction(Ctor) ? Ctor.prototype : undefined);
|
||||
}
|
||||
} else {
|
||||
accumulator = {};
|
||||
|
||||
Reference in New Issue
Block a user