source: imaps-frontend/node_modules/es-abstract/helpers/records/property-descriptor.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: 868 bytes
Line 
1'use strict';
2
3var $TypeError = require('es-errors/type');
4
5var hasOwn = require('hasown');
6
7var allowed = {
8 __proto__: null,
9 '[[Configurable]]': true,
10 '[[Enumerable]]': true,
11 '[[Get]]': true,
12 '[[Set]]': true,
13 '[[Value]]': true,
14 '[[Writable]]': true
15};
16
17// https://262.ecma-international.org/6.0/#sec-property-descriptor-specification-type
18
19module.exports = function isPropertyDescriptor(Desc) {
20 if (!Desc || typeof Desc !== 'object') {
21 return false;
22 }
23
24 for (var key in Desc) { // eslint-disable-line
25 if (hasOwn(Desc, key) && !allowed[key]) {
26 return false;
27 }
28 }
29
30 var isData = hasOwn(Desc, '[[Value]]') || hasOwn(Desc, '[[Writable]]');
31 var IsAccessor = hasOwn(Desc, '[[Get]]') || hasOwn(Desc, '[[Set]]');
32 if (isData && IsAccessor) {
33 throw new $TypeError('Property Descriptors may not be both accessor and data descriptors');
34 }
35 return true;
36};
Note: See TracBrowser for help on using the repository browser.