Repositorio del curso CCOM4030 el semestre B91 del proyecto Paz para la Mujer

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. 'use strict';
  2. var GetIntrinsic = require('../GetIntrinsic');
  3. var $TypeError = GetIntrinsic('%TypeError%');
  4. var $SyntaxError = GetIntrinsic('%SyntaxError%');
  5. var has = require('has');
  6. var predicates = {
  7. // https://ecma-international.org/ecma-262/6.0/#sec-property-descriptor-specification-type
  8. 'Property Descriptor': function isPropertyDescriptor(ES, Desc) {
  9. if (ES.Type(Desc) !== 'Object') {
  10. return false;
  11. }
  12. var allowed = {
  13. '[[Configurable]]': true,
  14. '[[Enumerable]]': true,
  15. '[[Get]]': true,
  16. '[[Set]]': true,
  17. '[[Value]]': true,
  18. '[[Writable]]': true
  19. };
  20. for (var key in Desc) { // eslint-disable-line
  21. if (has(Desc, key) && !allowed[key]) {
  22. return false;
  23. }
  24. }
  25. var isData = has(Desc, '[[Value]]');
  26. var IsAccessor = has(Desc, '[[Get]]') || has(Desc, '[[Set]]');
  27. if (isData && IsAccessor) {
  28. throw new $TypeError('Property Descriptors may not be both accessor and data descriptors');
  29. }
  30. return true;
  31. }
  32. };
  33. module.exports = function assertRecord(ES, recordType, argumentName, value) {
  34. var predicate = predicates[recordType];
  35. if (typeof predicate !== 'function') {
  36. throw new $SyntaxError('unknown record type: ' + recordType);
  37. }
  38. if (!predicate(ES, value)) {
  39. throw new $TypeError(argumentName + ' must be a ' + recordType);
  40. }
  41. };