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

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

Update repo after prototype presentation

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