_baseCreate.js 572 B

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