IsDataDescriptor.js 464 B

1234567891011121314151617181920212223
  1. 'use strict';
  2. var has = require('has');
  3. var assertRecord = require('../helpers/assertRecord');
  4. var Type = require('./Type');
  5. // https://ecma-international.org/ecma-262/6.0/#sec-isdatadescriptor
  6. module.exports = function IsDataDescriptor(Desc) {
  7. if (typeof Desc === 'undefined') {
  8. return false;
  9. }
  10. assertRecord(Type, 'Property Descriptor', 'Desc', Desc);
  11. if (!has(Desc, '[[Value]]') && !has(Desc, '[[Writable]]')) {
  12. return false;
  13. }
  14. return true;
  15. };