diff options
Diffstat (limited to 'src/node_modules/es-abstract/helpers/isPropertyDescriptor.js')
-rw-r--r-- | src/node_modules/es-abstract/helpers/isPropertyDescriptor.js | 31 |
1 files changed, 31 insertions, 0 deletions
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; +}; |