IsDataDescriptor.js 561 B

12345678910111213141516171819202122232425
  1. 'use strict';
  2. var $TypeError = require('es-errors/type');
  3. var hasOwn = require('hasown');
  4. var isPropertyDescriptor = require('../helpers/records/property-descriptor');
  5. // https://262.ecma-international.org/5.1/#sec-8.10.2
  6. module.exports = function IsDataDescriptor(Desc) {
  7. if (typeof Desc === 'undefined') {
  8. return false;
  9. }
  10. if (!isPropertyDescriptor(Desc)) {
  11. throw new $TypeError('Assertion failed: `Desc` must be a Property Descriptor');
  12. }
  13. if (!hasOwn(Desc, '[[Value]]') && !hasOwn(Desc, '[[Writable]]')) {
  14. return false;
  15. }
  16. return true;
  17. };