construct.js 794 B

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