Sha256: 1562819181315344f311f7fa981afe50cb65689a3503684a164dfa05c1ca47a5

Contents?: true

Size: 1.02 KB

Versions: 8

Compression:

Stored size: 1.02 KB

Contents

import _bindInstanceProperty from "../../core-js/instance/bind";
import _Reflect$construct from "../../core-js/reflect/construct";
import setPrototypeOf from "./setPrototypeOf";

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;
  }
}

export default 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 = _bindInstanceProperty(Function).apply(Parent, a);

      var instance = new Constructor();
      if (Class) setPrototypeOf(instance, Class.prototype);
      return instance;
    };
  }

  return _construct.apply(null, arguments);
}

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
condenser-0.2 lib/condenser/processors/node_modules/@babel/runtime-corejs3/helpers/esm/construct.js
condenser-0.1 lib/condenser/processors/node_modules/@babel/runtime-corejs3/helpers/esm/construct.js
condenser-0.0.12 lib/condenser/processors/node_modules/@babel/runtime-corejs3/helpers/esm/construct.js
condenser-0.0.11 lib/condenser/processors/node_modules/@babel/runtime-corejs3/helpers/esm/construct.js
condenser-0.0.10 lib/condenser/processors/node_modules/@babel/runtime-corejs3/helpers/esm/construct.js
condenser-0.0.9 lib/condenser/processors/node_modules/@babel/runtime-corejs3/helpers/esm/construct.js
condenser-0.0.8 lib/condenser/processors/node_modules/@babel/runtime-corejs3/helpers/esm/construct.js
condenser-0.0.7 lib/condenser/processors/node_modules/@babel/runtime-corejs3/helpers/esm/construct.js