index.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /**
  2. * lodash 3.1.1 (Custom Build) <https://lodash.com/>
  3. * Build: `lodash modern modularize exports="npm" -o ./`
  4. * Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/>
  5. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  6. * Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  7. * Available under MIT license <https://lodash.com/license>
  8. */
  9. var baseAssign = require('lodash._baseassign'),
  10. baseCreate = require('lodash._basecreate'),
  11. isIterateeCall = require('lodash._isiterateecall');
  12. /**
  13. * Creates an object that inherits from the given `prototype` object. If a
  14. * `properties` object is provided its own enumerable properties are assigned
  15. * to the created object.
  16. *
  17. * @static
  18. * @memberOf _
  19. * @category Object
  20. * @param {Object} prototype The object to inherit from.
  21. * @param {Object} [properties] The properties to assign to the object.
  22. * @param- {Object} [guard] Enables use as a callback for functions like `_.map`.
  23. * @returns {Object} Returns the new object.
  24. * @example
  25. *
  26. * function Shape() {
  27. * this.x = 0;
  28. * this.y = 0;
  29. * }
  30. *
  31. * function Circle() {
  32. * Shape.call(this);
  33. * }
  34. *
  35. * Circle.prototype = _.create(Shape.prototype, {
  36. * 'constructor': Circle
  37. * });
  38. *
  39. * var circle = new Circle;
  40. * circle instanceof Circle;
  41. * // => true
  42. *
  43. * circle instanceof Shape;
  44. * // => true
  45. */
  46. function create(prototype, properties, guard) {
  47. var result = baseCreate(prototype);
  48. if (guard && isIterateeCall(prototype, properties, guard)) {
  49. properties = undefined;
  50. }
  51. return properties ? baseAssign(result, properties) : result;
  52. }
  53. module.exports = create;