2016-10-10 03:43:44 +02:00
|
|
|
var baseAssign = require('./_baseAssign'),
|
|
|
|
baseCreate = require('./_baseCreate');
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates an object that inherits from the `prototype` object. If a
|
|
|
|
* `properties` object is given, its own enumerable string keyed properties
|
|
|
|
* are assigned to the created object.
|
|
|
|
*
|
|
|
|
* @static
|
|
|
|
* @memberOf _
|
|
|
|
* @since 2.3.0
|
|
|
|
* @category 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
|
|
|
|
*
|
|
|
|
* function Shape() {
|
|
|
|
* this.x = 0;
|
|
|
|
* this.y = 0;
|
|
|
|
* }
|
|
|
|
*
|
|
|
|
* function Circle() {
|
|
|
|
* Shape.call(this);
|
|
|
|
* }
|
|
|
|
*
|
|
|
|
* Circle.prototype = _.create(Shape.prototype, {
|
|
|
|
* 'constructor': Circle
|
|
|
|
* });
|
|
|
|
*
|
|
|
|
* var circle = new Circle;
|
|
|
|
* circle instanceof Circle;
|
|
|
|
* // => true
|
|
|
|
*
|
|
|
|
* circle instanceof Shape;
|
|
|
|
* // => true
|
|
|
|
*/
|
|
|
|
function create(prototype, properties) {
|
|
|
|
var result = baseCreate(prototype);
|
2016-11-03 01:33:53 +01:00
|
|
|
return properties == null ? result : baseAssign(result, properties);
|
2016-10-10 03:43:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = create;
|