File: .verb.md

package info (click to toggle)
node-is-accessor-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 (19 lines) | stat: -rw-r--r-- 432 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
## Usage

```js
const isAccessor = require('{%= name %}');
const obj = {
  get foo() {},
  bar: {get: function() {}}
};

isAccessor(obj, 'foo'); //=> true
isAccessor(obj, 'bar'); //=> false

// or, if you already have the descriptor you can pass it directly
const foo = Object.getOwnPropertyDescriptor(obj, 'foo');
isAccessor(foo); //=> true

const bar = Object.getOwnPropertyDescriptor(obj, 'bar');
isAccessor(bar); //=> false
```