mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-06 09:47:48 +00:00
Allow _.create to accept a properties object and rebuild docs and other builds.
This commit is contained in:
37
dist/lodash.underscore.js
vendored
37
dist/lodash.underscore.js
vendored
@@ -218,15 +218,16 @@
|
||||
*
|
||||
* The chainable wrapper functions are:
|
||||
* `after`, `assign`, `bind`, `bindAll`, `bindKey`, `chain`, `compact`,
|
||||
* `compose`, `concat`, `countBy`, `createCallback`, `curry`, `debounce`,
|
||||
* `defaults`, `defer`, `delay`, `difference`, `filter`, `flatten`, `forEach`,
|
||||
* `forEachRight`, `forIn`, `forInRight`, `forOwn`, `forOwnRight`, `functions`,
|
||||
* `groupBy`, `indexBy`, `initial`, `intersection`, `invert`, `invoke`, `keys`,
|
||||
* `map`, `max`, `memoize`, `merge`, `min`, `object`, `omit`, `once`, `pairs`,
|
||||
* `partial`, `partialRight`, `pick`, `pluck`, `pull`, `push`, `range`, `reject`,
|
||||
* `remove`, `rest`, `reverse`, `shuffle`, `slice`, `sort`, `sortBy`, `splice`,
|
||||
* `tap`, `throttle`, `times`, `toArray`, `transform`, `union`, `uniq`, `unshift`,
|
||||
* `unzip`, `values`, `where`, `without`, `wrap`, and `zip`
|
||||
* `compose`, `concat`, `countBy`, `create`, `createCallback`, `curry`,
|
||||
* `debounce`, `defaults`, `defer`, `delay`, `difference`, `filter`, `flatten`,
|
||||
* `forEach`, `forEachRight`, `forIn`, `forInRight`, `forOwn`, `forOwnRight`,
|
||||
* `functions`, `groupBy`, `indexBy`, `initial`, `intersection`, `invert`,
|
||||
* `invoke`, `keys`, `map`, `max`, `memoize`, `merge`, `min`, `object`, `omit`,
|
||||
* `once`, `pairs`, `partial`, `partialRight`, `pick`, `pluck`, `pull`, `push`,
|
||||
* `range`, `reject`, `remove`, `rest`, `reverse`, `shuffle`, `slice`, `sort`,
|
||||
* `sortBy`, `splice`, `tap`, `throttle`, `times`, `toArray`, `transform`,
|
||||
* `union`, `uniq`, `unshift`, `unzip`, `values`, `where`, `without`, `wrap`,
|
||||
* and `zip`
|
||||
*
|
||||
* The non-chainable wrapper functions are:
|
||||
* `clone`, `cloneDeep`, `contains`, `escape`, `every`, `find`, `findIndex`,
|
||||
@@ -973,12 +974,15 @@
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new object with the specified `prototype`.
|
||||
* Creates an object that inherits from the given `prototype` object. If a
|
||||
* `properties` object is provided its own enumerable properties are assigned
|
||||
* to the created object.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @category Objects
|
||||
* @param {Object} prototype The prototype object.
|
||||
* @param {Object} prototype The object to inherit from.
|
||||
* @param {Object} [properties] The properties to assign to the object.
|
||||
* @returns {Object} Returns the new object.
|
||||
* @example
|
||||
*
|
||||
@@ -991,8 +995,7 @@
|
||||
* Shape.call(this);
|
||||
* }
|
||||
*
|
||||
* Circle.prototype = _.create(Shape.prototype);
|
||||
* Circle.prototype.constructor = Circle;
|
||||
* Circle.prototype = _.create(Shape.prototype, { 'constructor': Circle });
|
||||
*
|
||||
* var circle = new Circle;
|
||||
* circle instanceof Circle
|
||||
@@ -1001,8 +1004,9 @@
|
||||
* circle instanceof Shape
|
||||
* // => true
|
||||
*/
|
||||
function create(prototype) {
|
||||
return isObject(prototype) ? nativeCreate(prototype) : {};
|
||||
function create(prototype, properties) {
|
||||
var result = isObject(prototype) ? nativeCreate(prototype) : {};
|
||||
return properties ? assign(result, properties) : result;
|
||||
}
|
||||
// fallback for browsers without `Object.create`
|
||||
if (!nativeCreate) {
|
||||
@@ -1012,7 +1016,8 @@
|
||||
var result = new noop;
|
||||
noop.prototype = null;
|
||||
}
|
||||
return result || {};
|
||||
result || (result = {});
|
||||
return properties ? assign(result, properties) : result;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user