No Description

_baseCreate.js 560B

1234567891011121314151617181920
  1. var isObject = require('./isObject.js');
  2. var _setup = require('./_setup.js');
  3. // Create a naked function reference for surrogate-prototype-swapping.
  4. function ctor() {
  5. return function(){};
  6. }
  7. // An internal function for creating a new object that inherits from another.
  8. function baseCreate(prototype) {
  9. if (!isObject(prototype)) return {};
  10. if (_setup.nativeCreate) return _setup.nativeCreate(prototype);
  11. var Ctor = ctor();
  12. Ctor.prototype = prototype;
  13. var result = new Ctor;
  14. Ctor.prototype = null;
  15. return result;
  16. }
  17. module.exports = baseCreate;