IsGenericDescriptor.js 627 B

1234567891011121314151617181920212223242526
  1. 'use strict';
  2. var $TypeError = require('es-errors/type');
  3. var IsAccessorDescriptor = require('./IsAccessorDescriptor');
  4. var IsDataDescriptor = require('./IsDataDescriptor');
  5. var isPropertyDescriptor = require('./IsPropertyDescriptor');
  6. // https://262.ecma-international.org/5.1/#sec-8.10.3
  7. module.exports = function IsGenericDescriptor(Desc) {
  8. if (typeof Desc === 'undefined') {
  9. return false;
  10. }
  11. if (!isPropertyDescriptor(Desc)) {
  12. throw new $TypeError('Assertion failed: `Desc` must be a Property Descriptor');
  13. }
  14. if (!IsAccessorDescriptor(Desc) && !IsDataDescriptor(Desc)) {
  15. return true;
  16. }
  17. return false;
  18. };