wrapNativeSuper.js 1.1 KB

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