_baseCreate.js 686 B

12345678910111213141516171819202122232425262728293031
  1. var isObject = require('./isObject');
  2. /** Built-in value references. */
  3. var objectCreate = Object.create;
  4. /**
  5. * The base implementation of `_.create` without support for assigning
  6. * properties to the created object.
  7. *
  8. * @private
  9. * @param {Object} proto The object to inherit from.
  10. * @returns {Object} Returns the new object.
  11. */
  12. var baseCreate = (function() {
  13. function object() {}
  14. return function(proto) {
  15. if (!isObject(proto)) {
  16. return {};
  17. }
  18. if (objectCreate) {
  19. return objectCreate(proto);
  20. }
  21. object.prototype = proto;
  22. var result = new object;
  23. object.prototype = undefined;
  24. return result;
  25. };
  26. }());
  27. module.exports = baseCreate;