construct.js 698 B

123456789101112131415161718
  1. import _Reflect$construct from "@babel/runtime-corejs2/core-js/reflect/construct";
  2. import setPrototypeOf from "./setPrototypeOf.js";
  3. import isNativeReflectConstruct from "./isNativeReflectConstruct.js";
  4. export default function _construct(Parent, args, Class) {
  5. if (isNativeReflectConstruct()) {
  6. _construct = _Reflect$construct.bind();
  7. } else {
  8. _construct = function _construct(Parent, args, Class) {
  9. var a = [null];
  10. a.push.apply(a, args);
  11. var Constructor = Function.bind.apply(Parent, a);
  12. var instance = new Constructor();
  13. if (Class) setPrototypeOf(instance, Class.prototype);
  14. return instance;
  15. };
  16. }
  17. return _construct.apply(null, arguments);
  18. }