From 46e43f4bde4a35785b4997b81e86cd19f046b69b Mon Sep 17 00:00:00 2001 From: Minteck Date: Tue, 21 Dec 2021 16:52:28 +0100 Subject: Commit --- .../es-abstract/helpers/isPropertyDescriptor.js | 31 ++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 src/node_modules/es-abstract/helpers/isPropertyDescriptor.js (limited to 'src/node_modules/es-abstract/helpers/isPropertyDescriptor.js') diff --git a/src/node_modules/es-abstract/helpers/isPropertyDescriptor.js b/src/node_modules/es-abstract/helpers/isPropertyDescriptor.js new file mode 100644 index 0000000..3eff7eb --- /dev/null +++ b/src/node_modules/es-abstract/helpers/isPropertyDescriptor.js @@ -0,0 +1,31 @@ +'use strict'; + +var GetIntrinsic = require('../GetIntrinsic'); + +var has = require('has'); +var $TypeError = GetIntrinsic('%TypeError%'); + +module.exports = function IsPropertyDescriptor(ES, Desc) { + if (ES.Type(Desc) !== 'Object') { + return false; + } + var allowed = { + '[[Configurable]]': true, + '[[Enumerable]]': true, + '[[Get]]': true, + '[[Set]]': true, + '[[Value]]': true, + '[[Writable]]': true + }; + + for (var key in Desc) { // eslint-disable-line no-restricted-syntax + if (has(Desc, key) && !allowed[key]) { + return false; + } + } + + if (ES.IsDataDescriptor(Desc) && ES.IsAccessorDescriptor(Desc)) { + throw new $TypeError('Property Descriptors may not be both accessor and data descriptors'); + } + return true; +}; -- cgit