Gathering detailed insights and metrics for @diotoborg/placeat-placeat
Gathering detailed insights and metrics for @diotoborg/placeat-placeat
Gathering detailed insights and metrics for @diotoborg/placeat-placeat
Gathering detailed insights and metrics for @diotoborg/placeat-placeat
npm install @diotoborg/placeat-placeat
Typescript
Module System
Node Version
NPM Version
71.6
Supply Chain
100
Quality
86.2
Maintenance
100
Vulnerability
100
License
JavaScript (100%)
Total Downloads
5,762
Last Day
99
Last Week
364
Last Month
1,823
Last Year
5,762
1,916 Commits
2 Watching
1 Branches
1 Contributors
Latest Version
4.8.88
Package Id
@diotoborg/placeat-placeat@4.8.88
Unpacked Size
171.74 kB
Size
89.53 kB
File Count
478
NPM Version
10.8.2
Node Version
20.17.0
Publised On
01 Sept 2024
Cumulative downloads
Total Downloads
Last day
160.5%
99
Compared to previous day
Last week
-3.7%
364
Compared to previous week
Last month
-6%
1,823
Compared to previous month
Last year
0%
5,762
Compared to previous year
29
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('@diotoborg/placeat-placeat'); 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.
No security vulnerabilities found.