UNPKG

prepack

Version:

Execute a JS bundle, serialize global state and side effects to a snapshot that can be quickly restored.

58 lines (46 loc) 1.92 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _index = require("./index.js"); var _babelTypes = require("babel-types"); var t = _interopRequireWildcard(_babelTypes); var _invariant = require("../invariant"); var _invariant2 = _interopRequireDefault(_invariant); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } /* Non built-in ECMAScript function objects with source code */ /** * Copyright (c) 2017-present, Facebook, Inc. * All rights reserved. * * This source code is licensed under the BSD-style license found in the * LICENSE file in the root directory of this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. */ class ECMAScriptSourceFunctionValue extends _index.ECMAScriptFunctionValue { constructor(realm, intrinsicName) { super(realm, intrinsicName); } // Override. getName() { const uniqueTag = this.$ECMAScriptCode.uniqueOrderedTag; // Should only be called after the function is initialized. (0, _invariant2.default)(uniqueTag); return this.__originalName ? this.__originalName : `f#${uniqueTag}`; } hasDefaultLength() { let params = this.$FormalParameters; let expected = params.length; for (let i = 0; i < params.length; i++) { let param = params[i]; if (t.isAssignmentPattern(param) || t.isRestElement(param)) { expected = i; break; } } return expected === this.getLength(); } } exports.default = ECMAScriptSourceFunctionValue; //# sourceMappingURL=ECMAScriptSourceFunctionValue.js.map