Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/es-abstract/helpers/isPropertyDescriptor.js')
-rw-r--r--node_modules/es-abstract/helpers/isPropertyDescriptor.js31
1 files changed, 31 insertions, 0 deletions
diff --git a/node_modules/es-abstract/helpers/isPropertyDescriptor.js b/node_modules/es-abstract/helpers/isPropertyDescriptor.js
new file mode 100644
index 000000000..3eff7eb8f
--- /dev/null
+++ b/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;
+};