index.js 355 B

12345678910111213141516
  1. 'use strict';
  2. var isAccessor = require('is-accessor-descriptor');
  3. var isData = require('is-data-descriptor');
  4. module.exports = function isDescriptor(obj, key) {
  5. if (!obj || (typeof obj !== 'object' && typeof obj !== 'function')) {
  6. return false;
  7. }
  8. if ('get' in obj || 'set' in obj) {
  9. return isAccessor(obj, key);
  10. }
  11. return isData(obj, key);
  12. };