UNPKG

2.09 kBJavaScriptView Raw
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.default = void 0;
7
8var _index = require("./index.js");
9
10var t = _interopRequireWildcard(require("@babel/types"));
11
12var _invariant = _interopRequireDefault(require("../invariant.js"));
13
14function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
16function _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)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
17
18/**
19 * Copyright (c) 2017-present, Facebook, Inc.
20 * All rights reserved.
21 *
22 * This source code is licensed under the BSD-style license found in the
23 * LICENSE file in the root directory of this source tree. An additional grant
24 * of patent rights can be found in the PATENTS file in the same directory.
25 */
26
27/* Non built-in ECMAScript function objects with source code */
28class ECMAScriptSourceFunctionValue extends _index.ECMAScriptFunctionValue {
29 constructor(realm, intrinsicName) {
30 super(realm, intrinsicName);
31 }
32
33 // Override.
34 getName() {
35 const uniqueTag = this.$ECMAScriptCode.uniqueOrderedTag; // Should only be called after the function is initialized.
36
37 (0, _invariant.default)(uniqueTag);
38 return this.__originalName ? this.__originalName : `f#${uniqueTag}`;
39 }
40
41 hasDefaultLength() {
42 let params = this.$FormalParameters;
43 let expected = params.length;
44
45 for (let i = 0; i < params.length; i++) {
46 let param = params[i];
47
48 if (t.isAssignmentPattern(param) || t.isRestElement(param)) {
49 expected = i;
50 break;
51 }
52 }
53
54 return expected === this.getLength();
55 }
56
57}
58
59exports.default = ECMAScriptSourceFunctionValue;
60//# sourceMappingURL=ECMAScriptSourceFunctionValue.js.map
\No newline at end of file