construct.js 858 B

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