main
Last change
on this file since d24f17c was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago |
Initial commit
|
-
Property mode
set to
100644
|
File size:
1.3 KB
|
Line | |
---|
1 | var getPrototypeOf = require("./getPrototypeOf.js");
|
---|
2 | var setPrototypeOf = require("./setPrototypeOf.js");
|
---|
3 | var isNativeFunction = require("./isNativeFunction.js");
|
---|
4 | var construct = require("./construct.js");
|
---|
5 | function _wrapNativeSuper(Class) {
|
---|
6 | var _cache = typeof Map === "function" ? new Map() : undefined;
|
---|
7 | module.exports = _wrapNativeSuper = function _wrapNativeSuper(Class) {
|
---|
8 | if (Class === null || !isNativeFunction(Class)) return Class;
|
---|
9 | if (typeof Class !== "function") {
|
---|
10 | throw new TypeError("Super expression must either be null or a function");
|
---|
11 | }
|
---|
12 | if (typeof _cache !== "undefined") {
|
---|
13 | if (_cache.has(Class)) return _cache.get(Class);
|
---|
14 | _cache.set(Class, Wrapper);
|
---|
15 | }
|
---|
16 | function Wrapper() {
|
---|
17 | return construct(Class, arguments, getPrototypeOf(this).constructor);
|
---|
18 | }
|
---|
19 | Wrapper.prototype = Object.create(Class.prototype, {
|
---|
20 | constructor: {
|
---|
21 | value: Wrapper,
|
---|
22 | enumerable: false,
|
---|
23 | writable: true,
|
---|
24 | configurable: true
|
---|
25 | }
|
---|
26 | });
|
---|
27 | return setPrototypeOf(Wrapper, Class);
|
---|
28 | }, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
---|
29 | return _wrapNativeSuper(Class);
|
---|
30 | }
|
---|
31 | module.exports = _wrapNativeSuper, module.exports.__esModule = true, module.exports["default"] = module.exports; |
---|
Note:
See
TracBrowser
for help on using the repository browser.