UNPKG

608 BJavaScriptView Raw
1import setPrototypeOf from "./setPrototypeOf.js";
2import isNativeReflectConstruct from "./isNativeReflectConstruct.js";
3export default function _construct(Parent, args, Class) {
4 if (isNativeReflectConstruct()) {
5 _construct = Reflect.construct;
6 } else {
7 _construct = function _construct(Parent, args, Class) {
8 var a = [null];
9 a.push.apply(a, args);
10 var Constructor = Function.bind.apply(Parent, a);
11 var instance = new Constructor();
12 if (Class) setPrototypeOf(instance, Class.prototype);
13 return instance;
14 };
15 }
16
17 return _construct.apply(null, arguments);
18}
\No newline at end of file