createSuper.js 766 B

1234567891011121314151617181920
  1. import _Reflect$construct from "@babel/runtime-corejs3/core-js/reflect/construct";
  2. import getPrototypeOf from "./getPrototypeOf.js";
  3. import isNativeReflectConstruct from "./isNativeReflectConstruct.js";
  4. import possibleConstructorReturn from "./possibleConstructorReturn.js";
  5. export default function _createSuper(Derived) {
  6. var hasNativeReflectConstruct = isNativeReflectConstruct();
  7. return function _createSuperInternal() {
  8. var Super = getPrototypeOf(Derived),
  9. result;
  10. if (hasNativeReflectConstruct) {
  11. var NewTarget = getPrototypeOf(this).constructor;
  12. result = _Reflect$construct(Super, arguments, NewTarget);
  13. } else {
  14. result = Super.apply(this, arguments);
  15. }
  16. return possibleConstructorReturn(this, result);
  17. };
  18. }