source: imaps-frontend/node_modules/es-abstract/2020/SetFunctionLength.js@ d565449

main
Last change on this file since d565449 was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 990 bytes
RevLine 
[d565449]1'use strict';
2
3var $TypeError = require('es-errors/type');
4
5var DefinePropertyOrThrow = require('./DefinePropertyOrThrow');
6var HasOwnProperty = require('./HasOwnProperty');
7var IsExtensible = require('./IsExtensible');
8var IsNonNegativeInteger = require('./IsNonNegativeInteger');
9
10// https://262.ecma-international.org/11.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 (!IsNonNegativeInteger(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.