Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

is-accessor-descriptor

inspect-js107.8mMIT3.0.5

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

accessor, check, data, descriptor, get, getter, is, keys, object, properties, property, set, setter, type, valid, value

readme

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));

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

changelog

Changelog

All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog and this project adheres to Semantic Versioning.

v3.0.5 - 2023-10-27

Commits

  • [Fix] fix a bad merge and refactor checkProto logic 1acdf9d

v3.0.4 - 2023-10-26

Commits

  • Merge tag v0.1.7, v1.0.1 a5ae905
  • [eslint] actually use eslint d0b9c94
  • [eslint] actually use eslint a05c057
  • [meta] update package.json, etc from main c4fab21
  • [readme] clean up docs, URLs, package.json, etc 6648dcd
  • temp a6392d4
  • [meta] update .gitignore cba0ea0
  • [Tests] switch to tape 9a0ab35
  • [readme] remove verb 2f07da4
  • [Tests] switch to tape 7e39202
  • [Tests] migrate from travis to github actions aa436b0
  • [Tests] migrate from travis to github actions 6e9c4f1
  • [readme] remove verb 967137d
  • [readme] use evalmd 471d3b9
  • [Fix] only one of get and set are required to be an accessor c8de5e7
  • [Fix] properly handle an accessor descriptor with only a setter 04647f4
  • [Refactor] use hasown 6151f01
  • [Refactor] properly guard for-in loop a0454cc
  • [Fix] allow any non-primitive; arrays and functions are objects too 853db5a
  • [Fix] allow any non-primitive; arrays and functions are objects too 123e3c3
  • Only apps should have lockfiles 87402b1
  • [Refactor] use hasown 7ad36a0
  • [Fix] use correct logic for two-arg form 3c1729e
  • [Fix] properly guard for-in loop 442daa8
  • [Tests] move tests to test dir 18313a7
  • [readme] fix incorrect example 3ee754a
  • [Tests] move tests to test dir 5d70880
  • [Dev Deps] add missing npmignore 97ce4bc
  • [Robustness] use a null object just in case 675af5b

v3.0.3 - 2023-10-25

Commits

  • [Dev Deps] update @ljharb/eslint-config, aud, has-property-descriptors, tape 908044d
  • [Refactor] use hasown 8b94cc1

v3.0.2 - 2023-04-27

Commits

  • [eslint] cleanup c0a3a34
  • [Tests] travis -> Github Actions; add safe-publish-latest, npmignore, auto-changelog, evalmd, aud a45de10
  • [readme] clean up docs, URLs, package.json, etc d2f3547
  • [New] increase support from node 6 down to node 0.4 825f88e
  • [Tests] convert from mocha to tape 072d097
  • [Docs] remove verb 7567b54
  • [Tests] use has-property-descriptors to skip true getter tests in older engines 0e26d80
  • [Fix] when an object/key pair is provided, check arguments.length instead of key truthiness 3962d00
  • [Tests] add coverage 6337da4
  • [meta] switch from files field to npmignore; add exports 6e870be

v3.0.1 - 2018-12-13

Commits

v3.0.0 - 2018-12-13

Commits

v2.0.0 - 2017-12-04

Commits

v1.0.1 - 2023-10-26

Commits

  • [eslint] actually use eslint a05c057
  • [readme] clean up docs, URLs, package.json, etc 6648dcd
  • [meta] update .gitignore cba0ea0
  • [readme] remove verb 2f07da4
  • [Tests] switch to tape 7e39202
  • [Tests] migrate from travis to github actions aa436b0
  • [Fix] properly handle an accessor descriptor with only a setter 04647f4
  • [Refactor] properly guard for-in loop a0454cc
  • [Fix] allow any non-primitive; arrays and functions are objects too 123e3c3
  • [Refactor] use hasown 7ad36a0
  • [readme] fix incorrect example 3ee754a
  • [Tests] move tests to test dir 5d70880
  • [Dev Deps] add missing npmignore 97ce4bc
  • [Robustness] use a null object just in case 675af5b

v1.0.0 - 2017-11-01

Merged

  • Pin mocha to version 3 to support Node 0.12 #3
  • Update kind-of to version 6.0 #2

Commits

v0.1.7 - 2023-10-26

Commits

  • [eslint] actually use eslint d0b9c94
  • [meta] update package.json, etc from main c4fab21
  • [Tests] switch to tape 9a0ab35
  • [Tests] migrate from travis to github actions 6e9c4f1
  • [readme] remove verb 967137d
  • [readme] use evalmd 471d3b9
  • [Fix] only one of get and set are required to be an accessor c8de5e7
  • [Refactor] use hasown 6151f01
  • [Fix] allow any non-primitive; arrays and functions are objects too 853db5a
  • Only apps should have lockfiles 87402b1
  • [Fix] use correct logic for two-arg form 3c1729e
  • [Fix] properly guard for-in loop 442daa8
  • [Tests] move tests to test dir 18313a7

v0.1.6 - 2015-12-28

Commits

v0.1.5 - 2015-12-28

Commits

  • run update 139251c
  • improve checks for valid/invalid properties de1be1e
  • use verb layout, add verb plugin for formatting markdown 2324242
  • run verb to generate readme 84587a4

v0.1.4 - 2015-12-20

Commits

v0.1.3 - 2015-10-04

Commits

v0.1.2 - 2015-10-04

Commits

v0.1.1 - 2015-08-31

Commits