Gathering detailed insights and metrics for is-data-descriptor
Gathering detailed insights and metrics for is-data-descriptor
Gathering detailed insights and metrics for is-data-descriptor
Gathering detailed insights and metrics for is-data-descriptor
Returns true if a value has the characteristics of a valid JavaScript data descriptor.
npm install is-data-descriptor
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
20 Stars
79 Commits
6 Forks
4 Watching
3 Branches
5 Contributors
Updated on 04 Aug 2024
Minified
Minified + Gzipped
JavaScript (100%)
Cumulative downloads
Total Downloads
Last day
-12.4%
7,971,219
Compared to previous day
Last week
3%
53,874,269
Compared to previous week
Last month
68.5%
184,767,762
Compared to previous month
Last year
-36.3%
1,580,160,032
Compared to previous year
Returns true if a value has the characteristics of a valid JavaScript data descriptor.
true
when the descriptor has valid properties with valid values.
false
when not an object or when the object has invalid properties.
1var isDataDesc = require('is-data-descriptor');
2var assert = require('assert');
3
4assert.equal(true, isDataDesc({ value: 'foo' }));
5assert.equal(true, isDataDesc({ value: function () {} }));
6assert.equal(true, isDataDesc({ value: true }));
7
8assert.equal(false, isDataDesc('a'));
9assert.equal(false, isDataDesc(null));
10assert.equal(false, isDataDesc([]));
11
12assert.equal(false, isDataDesc({ value: 'foo', bar: 'baz' }));
13assert.equal(false, isDataDesc({ value: 'foo', bar: 'baz' }));
14assert.equal(false, isDataDesc({ value: 'foo', get: function () {} }));
15assert.equal(false, isDataDesc({ get: function () {}, value: 'foo' }) );
16
17assert.equal(false, isDataDesc({ value: 'foo', enumerable: 'foo' }));
18assert.equal(false, isDataDesc({ value: 'foo', configurable: 'foo' }));
19assert.equal(false, isDataDesc({ value: 'foo', writable: 'foo' }));
The only valid data descriptor properties are the following:
configurable
(required)enumerable
(required)value
(optional)writable
(optional)To be a valid data descriptor, either value
or writable
must be defined.
Invalid properties
A descriptor may have additional invalid properties (an error will not be thrown).
1var foo = {};
2
3Object.defineProperty(foo, 'bar', {
4 enumerable: true,
5 whatever: 'blah', // invalid, but doesn't cause an error
6 get() {
7 return 'baz';
8 }
9});
10
11assert.equal(foo.bar, 'baz');
Simply clone the repo, npm install
, and run npm test
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
Reason
0 existing vulnerabilities detected
Reason
security policy file detected
Details
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
no SAST tool detected
Details
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Score
Last Scanned on 2024-11-18
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