You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							29 lines
						
					
					
						
							984 B
						
					
					
				
			
		
		
	
	
							29 lines
						
					
					
						
							984 B
						
					
					
				| 'use strict';
 | |
| 
 | |
| var $TypeError = require('es-errors/type');
 | |
| var isInteger = require('math-intrinsics/isInteger');
 | |
| 
 | |
| var DefinePropertyOrThrow = require('./DefinePropertyOrThrow');
 | |
| var HasOwnProperty = require('./HasOwnProperty');
 | |
| var IsExtensible = require('./IsExtensible');
 | |
| 
 | |
| // https://262.ecma-international.org/9.0/#sec-setfunctionlength
 | |
| 
 | |
| module.exports = function SetFunctionLength(F, length) {
 | |
| 	if (typeof F !== 'function' || !IsExtensible(F) || HasOwnProperty(F, 'length')) {
 | |
| 		throw new $TypeError('Assertion failed: `F` must be an extensible function and lack an own `length` property');
 | |
| 	}
 | |
| 	if (typeof length !== 'number') {
 | |
| 		throw new $TypeError('Assertion failed: `length` must be a Number');
 | |
| 	}
 | |
| 	if (length < 0 || !isInteger(length)) {
 | |
| 		throw new $TypeError('Assertion failed: `length` must be an integer >= 0');
 | |
| 	}
 | |
| 	return DefinePropertyOrThrow(F, 'length', {
 | |
| 		'[[Configurable]]': true,
 | |
| 		'[[Enumerable]]': false,
 | |
| 		'[[Value]]': length,
 | |
| 		'[[Writable]]': false
 | |
| 	});
 | |
| };
 |