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