Gathering detailed insights and metrics for @diotoborg/ex-repellat
Gathering detailed insights and metrics for @diotoborg/ex-repellat
Gathering detailed insights and metrics for @diotoborg/ex-repellat
Gathering detailed insights and metrics for @diotoborg/ex-repellat
npm install @diotoborg/ex-repellat
Typescript
Module System
Node Version
NPM Version
JavaScript (100%)
Total Downloads
5,043
Last Day
5
Last Week
316
Last Month
1,804
Last Year
5,043
1,988 Commits
1 Watching
1 Branches
1 Contributors
Latest Version
2.8.76
Package Id
@diotoborg/ex-repellat@2.8.76
Unpacked Size
181.35 kB
Size
93.82 kB
File Count
495
NPM Version
10.8.2
Node Version
20.17.0
Publised On
01 Sept 2024
Cumulative downloads
Total Downloads
Last day
-90.4%
5
Compared to previous day
Last week
-19.8%
316
Compared to previous week
Last month
-11%
1,804
Compared to previous month
Last year
0%
5,043
Compared to previous year
29
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('@diotoborg/ex-repellat');
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.
No security vulnerabilities found.