source: frontend/node_modules/es-abstract/2018/SetFunctionLength.js

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 984 bytes
RevLine 
[9af201e]1'use strict';
2
3var $TypeError = require('es-errors/type');
4var isInteger = require('math-intrinsics/isInteger');
5
6var DefinePropertyOrThrow = require('./DefinePropertyOrThrow');
7var HasOwnProperty = require('./HasOwnProperty');
8var IsExtensible = require('./IsExtensible');
9
10// https://262.ecma-international.org/9.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 < 0 || !isInteger(length)) {
20 throw new $TypeError('Assertion failed: `length` must be 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.