index.js 498 B

12345678910111213141516171819202122
  1. /*!
  2. * is-descriptor <https://github.com/jonschlinkert/is-descriptor>
  3. *
  4. * Copyright (c) 2015-2017, Jon Schlinkert.
  5. * Released under the MIT License.
  6. */
  7. 'use strict';
  8. var typeOf = require('kind-of');
  9. var isAccessor = require('is-accessor-descriptor');
  10. var isData = require('is-data-descriptor');
  11. module.exports = function isDescriptor(obj, key) {
  12. if (typeOf(obj) !== 'object') {
  13. return false;
  14. }
  15. if ('get' in obj) {
  16. return isAccessor(obj, key);
  17. }
  18. return isData(obj, key);
  19. };