is-accessor-descriptor
Returns true if a value has the characteristics of a valid JavaScript accessor descriptor.
Last updated 9 years ago by jonschlinkert .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install is-accessor-descriptor 
SYNC missed versions from official npm registry.

is-accessor-descriptor Version Badge

github actions coverage License Downloads

npm badge

Returns true if a value has the characteristics of a valid JavaScript accessor descriptor.

Examples

const isAccessorDescriptor = require('is-accessor-descriptor');
const assert = require('assert');

const obj = {
	get foo() {},
	bar: { get: function() {} }
};

assert.equal(true, isAccessorDescriptor(obj, 'foo'));
assert.equal(false, isAccessorDescriptor(obj, 'bar'));

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

const bar = Object.getOwnPropertyDescriptor(obj, 'bar');
assert.equal(false, isAccessorDescriptor(bar));

Related projects

You might also be interested in these projects:

  • is-data-descriptor: Returns true if a value has the characteristics of a valid JavaScript data descriptor.
  • is-descriptor: Returns true if a value has the characteristics of a valid JavaScript descriptor. Works for… more
  • is-object: Returns true if the value is an object and not an array or null.

Tests

Simply clone the repo, npm install, and run npm test

Current Tags

  • 3.0.5                                ...           latest (a year ago)
  • 0.1.7                                ...           v0-backport (a year ago)
  • 1.0.1                                ...           v1-backport (a year ago)

16 Versions

  • 3.0.5                                ...           a year ago
  • 3.0.4 [deprecated]           ...           a year ago
  • 0.1.7                                ...           a year ago
  • 1.0.1                                ...           a year ago
  • 3.0.3                                ...           a year ago
  • 3.0.2                                ...           2 years ago
  • 3.0.1                                ...           6 years ago
  • 3.0.0                                ...           6 years ago
  • 2.0.0                                ...           7 years ago
  • 1.0.0 [deprecated]           ...           7 years ago
  • 0.1.6 [deprecated]           ...           9 years ago
  • 0.1.5                                ...           9 years ago
  • 0.1.4                                ...           9 years ago
  • 0.1.3                                ...           9 years ago
  • 0.1.2                                ...           9 years ago
  • 0.1.0                                ...           9 years ago
Maintainers (1)
Downloads
Total 7
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (1)
Dev Dependencies (2)

© 2010 - cnpmjs.org x YWFE | Home | YWFE