2f120c8ebf617f28c7474d9196996e4222968571
[yaffs-website] / node_modules / uncss / node_modules / lodash / create.js
1 var baseAssign = require('./internal/baseAssign'),
2     baseCreate = require('./internal/baseCreate');
3
4 /**
5  * Creates an object that inherits from the `prototype` object. If a `properties`
6  * object is provided its own enumerable properties are assigned to the created object.
7  *
8  * @static
9  * @memberOf _
10  * @category Object
11  * @param {Object} prototype The object to inherit from.
12  * @param {Object} [properties] The properties to assign to the object.
13  * @returns {Object} Returns the new object.
14  * @example
15  *
16  * function Shape() {
17  *   this.x = 0;
18  *   this.y = 0;
19  * }
20  *
21  * function Circle() {
22  *   Shape.call(this);
23  * }
24  *
25  * Circle.prototype = _.create(Shape.prototype, {
26  *   'constructor': Circle
27  * });
28  *
29  * var circle = new Circle;
30  * circle instanceof Circle;
31  * // => true
32  *
33  * circle instanceof Shape;
34  * // => true
35  */
36 function create(prototype, properties) {
37   var result = baseCreate(prototype);
38   return properties ? baseAssign(result, properties) : result;
39 }
40
41 module.exports = create;