@juigorg/nisi-molestiae-ut

2.0.14 • Public • Published

@juigorg/nisi-molestiae-ut 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('@juigorg/nisi-molestiae-ut');
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

Readme

Keywords

Package Sidebar

Install

npm i @juigorg/nisi-molestiae-ut

Weekly Downloads

6,333

Version

2.0.14

License

MIT

Unpacked Size

19.1 kB

Total Files

9

Last publish

Collaborators

  • tiengiangb47