source: imaps-frontend/node_modules/es-abstract/2023/SetFunctionLength.js@ 79a0317

main
Last change on this file since 79a0317 was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 3 days ago

F4 Finalna Verzija

  • Property mode set to 100644
File size: 1018 bytes
RevLine 
[d565449]1'use strict';
2
3var $TypeError = require('es-errors/type');
[79a0317]4var isInteger = require('math-intrinsics/isInteger');
[d565449]5
6var DefinePropertyOrThrow = require('./DefinePropertyOrThrow');
7var HasOwnProperty = require('./HasOwnProperty');
8var IsExtensible = require('./IsExtensible');
9
10// https://262.ecma-international.org/12.0/#sec-setfunctionlength
11
12module.exports = function SetFunctionLength(F, length) {
13 if (typeof F !== 'function' || !IsExtensible(F) || HasOwnProperty(F, 'length')) {
14 throw new $TypeError('Assertion failed: `F` must be an extensible function and lack an own `length` property');
15 }
16 if (typeof length !== 'number') {
17 throw new $TypeError('Assertion failed: `length` must be a Number');
18 }
19 if (length !== Infinity && (!isInteger(length) || length < 0)) {
20 throw new $TypeError('Assertion failed: `length` must be ∞, or an integer >= 0');
21 }
22 return DefinePropertyOrThrow(F, 'length', {
23 '[[Configurable]]': true,
24 '[[Enumerable]]': false,
25 '[[Value]]': length,
26 '[[Writable]]': false
27 });
28};
Note: See TracBrowser for help on using the repository browser.