construct.js 899 B

12345678910111213141516171819202122
  1. var setPrototypeOf = require("./setPrototypeOf.js");
  2. var isNativeReflectConstruct = require("./isNativeReflectConstruct.js");
  3. function _construct(Parent, args, Class) {
  4. if (isNativeReflectConstruct()) {
  5. module.exports = _construct = Reflect.construct, module.exports.__esModule = true, module.exports["default"] = module.exports;
  6. } else {
  7. module.exports = _construct = function _construct(Parent, args, Class) {
  8. var a = [null];
  9. a.push.apply(a, args);
  10. var Constructor = Function.bind.apply(Parent, a);
  11. var instance = new Constructor();
  12. if (Class) setPrototypeOf(instance, Class.prototype);
  13. return instance;
  14. }, module.exports.__esModule = true, module.exports["default"] = module.exports;
  15. }
  16. return _construct.apply(null, arguments);
  17. }
  18. module.exports = _construct, module.exports.__esModule = true, module.exports["default"] = module.exports;