1 | var _Reflect$construct = require("../core-js/reflect/construct.js");
|
2 |
|
3 | var setPrototypeOf = require("./setPrototypeOf");
|
4 |
|
5 | function isNativeReflectConstruct() {
|
6 | if (typeof Reflect === "undefined" || !_Reflect$construct) return false;
|
7 | if (_Reflect$construct.sham) return false;
|
8 | if (typeof Proxy === "function") return true;
|
9 |
|
10 | try {
|
11 | Date.prototype.toString.call(_Reflect$construct(Date, [], function () {}));
|
12 | return true;
|
13 | } catch (e) {
|
14 | return false;
|
15 | }
|
16 | }
|
17 |
|
18 | function _construct(Parent, args, Class) {
|
19 | if (isNativeReflectConstruct()) {
|
20 | module.exports = _construct = _Reflect$construct;
|
21 | } else {
|
22 | module.exports = _construct = function _construct(Parent, args, Class) {
|
23 | var a = [null];
|
24 | a.push.apply(a, args);
|
25 | var Constructor = Function.bind.apply(Parent, a);
|
26 | var instance = new Constructor();
|
27 | if (Class) setPrototypeOf(instance, Class.prototype);
|
28 | return instance;
|
29 | };
|
30 | }
|
31 |
|
32 | return _construct.apply(null, arguments);
|
33 | }
|
34 |
|
35 | module.exports = _construct; |
\ | No newline at end of file |