UNPKG

1.51 kBJavaScriptView Raw
1import _Object$create from "../../core-js/object/create";
2import _Map from "../../core-js/map";
3import _Reflect$construct from "../../core-js/reflect/construct";
4import _typeof from "../../helpers/es6/typeof";
5import _Object$setPrototypeOf from "../../core-js/object/set-prototype-of";
6import _Object$getPrototypeOf from "../../core-js/object/get-prototype-of";
7
8var _gPO = _Object$getPrototypeOf || function _gPO(o) {
9 return o.__proto__;
10};
11
12var _sPO = _Object$setPrototypeOf || function _sPO(o, p) {
13 o.__proto__ = p;
14 return o;
15};
16
17var _construct = _typeof(Reflect) === "object" && _Reflect$construct || function _construct(Parent, args, Class) {
18 var Constructor,
19 a = [null];
20 a.push.apply(a, args);
21 Constructor = Parent.bind.apply(Parent, a);
22 return _sPO(new Constructor(), Class.prototype);
23};
24
25var _cache = typeof _Map === "function" && new _Map();
26
27export default function _wrapNativeSuper(Class) {
28 if (typeof Class !== "function") {
29 throw new TypeError("Super expression must either be null or a function");
30 }
31
32 if (typeof _cache !== "undefined") {
33 if (_cache.has(Class)) return _cache.get(Class);
34
35 _cache.set(Class, Wrapper);
36 }
37
38 function Wrapper() {}
39
40 Wrapper.prototype = _Object$create(Class.prototype, {
41 constructor: {
42 value: Wrapper,
43 enumerable: false,
44 writeable: true,
45 configurable: true
46 }
47 });
48 return _sPO(Wrapper, _sPO(function Super() {
49 return _construct(Class, arguments, _gPO(this).constructor);
50 }, Class));
51}
\No newline at end of file