UNPKG

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