File: index.js

package info (click to toggle)
node-is-descriptor 2.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 112 kB
  • sloc: makefile: 4; sh: 2
file content (22 lines) | stat: -rw-r--r-- 560 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
/*!
 * is-descriptor <https://github.com/jonschlinkert/is-descriptor>
 *
 * Copyright (c) 2015-2017, Jon Schlinkert.
 * Released under the MIT License.
 */

'use strict';

var typeOf = require('kind-of');
var isAccessor = require('is-accessor-descriptor');
var isData = require('is-data-descriptor');

module.exports = function isDescriptor(obj, key, checkProto) {
  if (typeOf(obj) !== 'object') {
    return false;
  }
  if (checkProto || (!('get' in obj) && !('set' in obj))) {
    return isData(obj, key, checkProto);
  }
  return isAccessor(obj, key);
};