You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
705 B

4 years ago
  1. 'use strict';
  2. var GetIntrinsic = require('../GetIntrinsic');
  3. var has = require('has');
  4. var $TypeError = GetIntrinsic('%TypeError%');
  5. module.exports = function IsPropertyDescriptor(ES, Desc) {
  6. if (ES.Type(Desc) !== 'Object') {
  7. return false;
  8. }
  9. var allowed = {
  10. '[[Configurable]]': true,
  11. '[[Enumerable]]': true,
  12. '[[Get]]': true,
  13. '[[Set]]': true,
  14. '[[Value]]': true,
  15. '[[Writable]]': true
  16. };
  17. for (var key in Desc) { // eslint-disable-line
  18. if (has(Desc, key) && !allowed[key]) {
  19. return false;
  20. }
  21. }
  22. if (ES.IsDataDescriptor(Desc) && ES.IsAccessorDescriptor(Desc)) {
  23. throw new $TypeError('Property Descriptors may not be both accessor and data descriptors');
  24. }
  25. return true;
  26. };