No Description

_baseCreate.js 535B

123456789101112131415161718
  1. import isObject from './isObject.js';
  2. import { nativeCreate } from './_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. export default function baseCreate(prototype) {
  9. if (!isObject(prototype)) return {};
  10. if (nativeCreate) return nativeCreate(prototype);
  11. var Ctor = ctor();
  12. Ctor.prototype = prototype;
  13. var result = new Ctor;
  14. Ctor.prototype = null;
  15. return result;
  16. }