wrapNativeSuper.js 984 B

123456789101112131415161718192021222324252627
  1. import getPrototypeOf from "./getPrototypeOf.js";
  2. import setPrototypeOf from "./setPrototypeOf.js";
  3. import isNativeFunction from "./isNativeFunction.js";
  4. import construct from "./construct.js";
  5. function _wrapNativeSuper(t) {
  6. var r = "function" == typeof Map ? new Map() : void 0;
  7. return _wrapNativeSuper = function _wrapNativeSuper(t) {
  8. if (null === t || !isNativeFunction(t)) return t;
  9. if ("function" != typeof t) throw new TypeError("Super expression must either be null or a function");
  10. if (void 0 !== r) {
  11. if (r.has(t)) return r.get(t);
  12. r.set(t, Wrapper);
  13. }
  14. function Wrapper() {
  15. return construct(t, arguments, getPrototypeOf(this).constructor);
  16. }
  17. return Wrapper.prototype = Object.create(t.prototype, {
  18. constructor: {
  19. value: Wrapper,
  20. enumerable: !1,
  21. writable: !0,
  22. configurable: !0
  23. }
  24. }), setPrototypeOf(Wrapper, t);
  25. }, _wrapNativeSuper(t);
  26. }
  27. export { _wrapNativeSuper as default };