Gathering detailed insights and metrics for is-descriptor
Gathering detailed insights and metrics for is-descriptor
Gathering detailed insights and metrics for is-descriptor
Gathering detailed insights and metrics for is-descriptor
is-accessor-descriptor
Returns true if a value has the characteristics of a valid JavaScript accessor descriptor.
is-data-descriptor
Returns true if a value has the characteristics of a valid JavaScript data descriptor.
@types/is-data-descriptor
TypeScript definitions for is-data-descriptor
is-media-descriptor
Is given string a valid media descriptor (including media query)?
Returns true if a value has the characteristics of a valid JavaScript descriptor. Works for data descriptors and accessor descriptors.
npm install is-descriptor
Typescript
Module System
Min. Node Version
Node Version
NPM Version
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
12 Stars
67 Commits
4 Forks
4 Watchers
3 Branches
5 Contributors
Updated on Feb 14, 2023
Latest Version
3.1.1
Package Id
is-descriptor@3.1.1
Unpacked Size
27.21 kB
Size
7.42 kB
File Count
11
NPM Version
10.2.0
Node Version
21.0.0
Published on
Oct 28, 2023
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
Returns true if a value has the characteristics of a valid JavaScript descriptor. Works for fully completed data descriptors and accessor descriptors.
1const isDescriptor = require('is-descriptor'); 2const assert = require('assert'); 3 4const defaults = { configurable: false, enumerable: false }; 5const dataDefaults = { ...defaults, writable: false}; 6 7assert.ok(isDescriptor({ ...dataDefaults, value: 'foo' })); 8assert.ok(isDescriptor({ ...defaults, get() {}, set() {} })); 9assert.ok(!isDescriptor({ ...defaults, get: 'foo', set() {} }));
You may also check for a descriptor by passing an object as the first argument and property name (string
) as the second argument.
1const obj = { foo: 'abc' };
2
3Object.defineProperty(obj, 'bar', { value: 'xyz' });
4Reflect.defineProperty(obj, 'baz', { value: 'xyz' });
5
6assert.equal(isDescriptor(obj, 'foo'), true);
7assert.equal(isDescriptor(obj, 'bar'), true);
8assert.equal(isDescriptor(obj, 'baz'), true);
Returns false
when not an object
1assert.equal(isDescriptor('a'), false);
2assert.equal(isDescriptor(null), false);
3assert.equal(isDescriptor([]), false);
Returns true
when the object has valid properties with valid values.
1assert.equal(isDescriptor({ ...dataDefaults, value: 'foo' }), true);
2assert.equal(isDescriptor({ ...dataDefaults, value() {} }), true);
Returns false
when the object has invalid properties
1assert.equal(isDescriptor({ ...dataDefaults, value: 'foo', bar: 'baz' }), false);
2assert.equal(isDescriptor({ ...dataDefaults, value: 'foo', bar: 'baz' }), false);
3assert.equal(isDescriptor({ ...dataDefaults, value: 'foo', enumerable: 'baz' }), false);
4assert.equal(isDescriptor({ ...dataDefaults, value: 'foo', configurable: 'baz' }), false);
5assert.equal(isDescriptor({ ...dataDefaults, value: 'foo', get() {} }), false);
6assert.equal(isDescriptor({ ...dataDefaults, get() {}, value() {} }), false);
false
when a value is not the correct type
1assert.equal(isDescriptor({ ...dataDefaults, value: 'foo', enumerable: 'foo' }), false);
2assert.equal(isDescriptor({ ...dataDefaults, value: 'foo', configurable: 'foo' }), false);
3assert.equal(isDescriptor({ ...dataDefaults, value: 'foo', writable: 'foo' }), false);
true
when the object has valid properties with valid values.
1assert.equal(isDescriptor({ ...defaults, get() {}, set() {} }), true); 2assert.equal(isDescriptor({ ...defaults, get() {} }), true); 3assert.equal(isDescriptor({ ...defaults, set() {} }), true);
false
when the object has invalid properties
1assert.equal(isDescriptor({ ...defaults, get() {}, set() {}, bar: 'baz' }), false); 2assert.equal(isDescriptor({ ...defaults, get() {}, set() {}, enumerable: 'baz' }), false); 3assert.equal(isDescriptor({ ...defaults, get() {}, writable: true }), false); 4assert.equal(isDescriptor({ ...defaults, get() {}, value: true }), false);
Returns false
when an accessor is not a function
1assert.equal(isDescriptor({ ...defaults, get() {}, set: 'baz' }), false);
2assert.equal(isDescriptor({ ...defaults, get: 'foo', set() {} }), false);
3assert.equal(isDescriptor({ ...defaults, get: 'foo', bar: 'baz' }), false);
4assert.equal(isDescriptor({ ...defaults, get: 'foo', set: 'baz' }), false);
Returns false
when a value is not the correct type
1assert.equal(isDescriptor({ ...defaults, get() {}, set() {}, enumerable: 'foo' }), false); 2assert.equal(isDescriptor({ ...defaults, set() {}, configurable: 'foo' }), false); 3assert.equal(isDescriptor({ ...defaults, get() {}, configurable: 'foo' }), false);
You might also be interested in these projects:
Simply clone the repo, npm install
, and run npm test
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
security policy file detected
Details
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no SAST tool detected
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More