1
|
var setPrototypeOf = require("./setPrototypeOf");
|
2
|
|
3
|
var isNativeReflectConstruct = require("./isNativeReflectConstruct");
|
4
|
|
5
|
function _construct(Parent, args, Class) {
|
6
|
if (isNativeReflectConstruct()) {
|
7
|
module.exports = _construct = Reflect.construct;
|
8
|
} else {
|
9
|
module.exports = _construct = function _construct(Parent, args, Class) {
|
10
|
var a = [null];
|
11
|
a.push.apply(a, args);
|
12
|
var Constructor = Function.bind.apply(Parent, a);
|
13
|
var instance = new Constructor();
|
14
|
if (Class) setPrototypeOf(instance, Class.prototype);
|
15
|
return instance;
|
16
|
};
|
17
|
}
|
18
|
|
19
|
return _construct.apply(null, arguments);
|
20
|
}
|
21
|
|
22
|
module.exports = _construct;
|