source: imaps-frontend/node_modules/es-abstract/2016/TestIntegrityLevel.js@ 79a0317

main
Last change on this file since 79a0317 was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 3 days ago

F4 Finalna Verzija

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