You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
686 B

4 years ago
  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;