source: imaps-frontend/node_modules/es-abstract/2023/TestIntegrityLevel.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: 1.2 KB
Line 
1'use strict';
2
3var $gOPD = require('gopd');
4var $TypeError = require('es-errors/type');
5
6var every = require('../helpers/every');
7var OwnPropertyKeys = require('../helpers/OwnPropertyKeys');
8
9var IsDataDescriptor = require('./IsDataDescriptor');
10var IsExtensible = require('./IsExtensible');
11var ToPropertyDescriptor = require('./ToPropertyDescriptor');
12var Type = require('./Type');
13
14// https://262.ecma-international.org/6.0/#sec-testintegritylevel
15
16module.exports = function TestIntegrityLevel(O, level) {
17 if (Type(O) !== 'Object') {
18 throw new $TypeError('Assertion failed: Type(O) is not Object');
19 }
20 if (level !== 'sealed' && level !== 'frozen') {
21 throw new $TypeError('Assertion failed: `level` must be `"sealed"` or `"frozen"`');
22 }
23 var status = IsExtensible(O);
24 if (status) {
25 return false;
26 }
27 var theKeys = OwnPropertyKeys(O);
28 return theKeys.length === 0 || every(theKeys, function (k) {
29 var currentDesc = $gOPD(O, k);
30 if (typeof currentDesc !== 'undefined') {
31 if (currentDesc.configurable) {
32 return false;
33 }
34 if (level === 'frozen' && IsDataDescriptor(ToPropertyDescriptor(currentDesc)) && currentDesc.writable) {
35 return false;
36 }
37 }
38 return true;
39 });
40};
Note: See TracBrowser for help on using the repository browser.