simple-squiggle

A restricted subset of Squiggle
Log | Files | Refs | README

construct.js (899B)


      1 var setPrototypeOf = require("./setPrototypeOf.js");
      2 
      3 var isNativeReflectConstruct = require("./isNativeReflectConstruct.js");
      4 
      5 function _construct(Parent, args, Class) {
      6   if (isNativeReflectConstruct()) {
      7     module.exports = _construct = Reflect.construct, module.exports.__esModule = true, module.exports["default"] = module.exports;
      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     }, module.exports.__esModule = true, module.exports["default"] = module.exports;
     17   }
     18 
     19   return _construct.apply(null, arguments);
     20 }
     21 
     22 module.exports = _construct, module.exports.__esModule = true, module.exports["default"] = module.exports;