| "use strict"; |
| Object.defineProperty(exports, "__esModule", { value: true }); |
| exports.wrapNativeSuper = wrapNativeSuper; |
| |
| function wrapNativeSuper(Class) { |
| var _cache = typeof Map === "function" ? new Map() : undefined; |
| |
| exports.wrapNativeSuper = wrapNativeSuper = function wrapNativeSuper(Class) { |
| if (Class === null || !_isNativeFunction(Class)) |
| return Class; |
| if (typeof Class !== "function") { |
| throw new TypeError("Super expression must either be null or a function"); |
| } |
| if (typeof _cache !== "undefined") { |
| if (_cache.has(Class)) |
| return _cache.get(Class); |
| _cache.set(Class, Wrapper); |
| } |
| function Wrapper() { |
| |
| return _construct(Class, arguments, _getPrototypeOf(this).constructor); |
| } |
| Wrapper.prototype = Object.create(Class.prototype, { |
| constructor: { |
| value: Wrapper, |
| enumerable: false, |
| writable: true, |
| configurable: true, |
| }, |
| }); |
| return _setPrototypeOf(Wrapper, Class); |
| }; |
| return wrapNativeSuper(Class); |
| } |
| function isNativeReflectConstruct() { |
| if (typeof Reflect === "undefined" || !Reflect.construct) |
| return false; |
| |
| if (Reflect.construct.sham) |
| return false; |
| if (typeof Proxy === "function") |
| return true; |
| try { |
| Date.prototype.toString.call(Reflect.construct(Date, [], function () { })); |
| return true; |
| } |
| catch (e) { |
| return false; |
| } |
| } |
| |
| function _construct(Parent, args, Class) { |
| if (isNativeReflectConstruct()) { |
| |
| _construct = Reflect.construct; |
| } |
| else { |
| |
| _construct = function _construct(Parent, args, Class) { |
| var a = [null]; |
| a.push.apply(a, args); |
| |
| var Constructor = Function.bind.apply(Parent, a); |
| |
| var instance = new Constructor(); |
| if (Class) |
| _setPrototypeOf(instance, Class.prototype); |
| return instance; |
| }; |
| } |
| |
| return _construct.apply(null, arguments); |
| } |
| function _isNativeFunction(fn) { |
| return Function.toString.call(fn).indexOf("[native code]") !== -1; |
| } |
| |
| function _setPrototypeOf(o, p) { |
| |
| _setPrototypeOf = |
| Object.setPrototypeOf || |
| |
| function _setPrototypeOf(o, p) { |
| o.__proto__ = p; |
| return o; |
| }; |
| return _setPrototypeOf(o, p); |
| } |
| |
| function _getPrototypeOf(o) { |
| |
| _getPrototypeOf = Object.setPrototypeOf |
| ? Object.getPrototypeOf |
| : function _getPrototypeOf( |
| |
| o) { |
| return o.__proto__ || Object.getPrototypeOf(o); |
| }; |
| return _getPrototypeOf(o); |
| } |
| module.exports = { |
| wrapNativeSuper, |
| }; |
|
|