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
|
Line | |
---|
1 | 'use strict';
|
---|
2 |
|
---|
3 | var $TypeError = require('es-errors/type');
|
---|
4 |
|
---|
5 | var DefinePropertyOrThrow = require('./DefinePropertyOrThrow');
|
---|
6 | var HasOwnProperty = require('./HasOwnProperty');
|
---|
7 | var IsExtensible = require('./IsExtensible');
|
---|
8 | var IsNonNegativeInteger = require('./IsNonNegativeInteger');
|
---|
9 |
|
---|
10 | // https://262.ecma-international.org/11.0/#sec-setfunctionlength
|
---|
11 |
|
---|
12 | module.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.