6.14.107 • Published 2 months ago

@devtea2026/in-nam-corporis-quis v6.14.107

Weekly downloads
-
License
MIT
Repository
github
Last release
2 months ago

@devtea2026/in-nam-corporis-quis Version Badge

github actions coverage License Downloads

npm badge

Returns true if a value has the characteristics of a valid JavaScript data descriptor.

Examples

true when the descriptor has valid properties with valid values. false when not an object or when the object has invalid properties.

var isDataDesc = require('@devtea2026/in-nam-corporis-quis');
var assert = require('assert');

assert.equal(true, isDataDesc({ value: 'foo' }));
assert.equal(true, isDataDesc({ value: function () {} }));
assert.equal(true, isDataDesc({ value: true }));

assert.equal(false, isDataDesc('a'));
assert.equal(false, isDataDesc(null));
assert.equal(false, isDataDesc([]));

assert.equal(false, isDataDesc({ value: 'foo', bar: 'baz' }));
assert.equal(false, isDataDesc({ value: 'foo', bar: 'baz' }));
assert.equal(false, isDataDesc({ value: 'foo', get: function () {} }));
assert.equal(false, isDataDesc({ get: function () {}, value: 'foo' }) );
 
assert.equal(false, isDataDesc({ value: 'foo', enumerable: 'foo' }));
assert.equal(false, isDataDesc({ value: 'foo', configurable: 'foo' }));
assert.equal(false, isDataDesc({ value: 'foo', writable: 'foo' }));

Valid properties

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).

var foo = {};

Object.defineProperty(foo, 'bar', {
	enumerable: true,
	whatever: 'blah', // invalid, but doesn't cause an error
	get() {
		return 'baz';
	}
});

assert.equal(foo.bar, 'baz');

Related projects

  • is-accessor-descriptor: Returns true if a value has the characteristics of a valid JavaScript accessor descriptor.
  • is-descriptor: Returns true if a value has the characteristics of a valid JavaScript descriptor. Works for… more

Tests

Simply clone the repo, npm install, and run npm test

6.14.107

2 months ago

6.14.106

2 months ago

6.14.105

2 months ago

6.14.104

2 months ago

6.14.103

2 months ago

6.14.102

2 months ago

6.14.101

2 months ago

6.14.100

2 months ago

4.13.77

3 months ago

4.13.78

3 months ago

4.13.76

3 months ago

4.13.79

3 months ago

4.6.44

4 months ago

4.6.45

4 months ago

4.6.42

4 months ago

4.6.43

4 months ago

4.6.48

4 months ago

4.6.49

4 months ago

4.6.46

4 months ago

4.6.47

4 months ago

4.10.74

3 months ago

4.10.75

3 months ago

6.14.93

2 months ago

6.14.92

2 months ago

6.14.95

2 months ago

6.14.94

2 months ago

3.5.29

5 months ago

3.5.28

5 months ago

6.14.91

2 months ago

3.5.27

5 months ago

6.14.90

3 months ago

3.5.26

5 months ago

6.14.97

2 months ago

6.14.96

2 months ago

6.14.99

2 months ago

6.14.98

2 months ago

3.4.25

5 months ago

5.13.82

3 months ago

3.4.26

5 months ago

5.13.83

3 months ago

5.13.84

3 months ago

4.6.62

4 months ago

4.6.63

4 months ago

4.6.60

4 months ago

3.4.23

5 months ago

4.6.61

4 months ago

3.4.24

5 months ago

4.6.66

4 months ago

2.4.18

5 months ago

4.6.67

4 months ago

2.4.17

5 months ago

4.6.64

4 months ago

4.6.65

4 months ago

2.4.19

5 months ago

4.6.68

4 months ago

5.13.89

3 months ago

5.13.85

3 months ago

5.13.86

3 months ago

5.13.87

3 months ago

5.13.88

3 months ago

4.12.76

3 months ago

4.8.72

3 months ago

4.6.51

4 months ago

4.6.52

4 months ago

4.6.50

4 months ago

4.6.55

4 months ago

4.6.56

4 months ago

4.6.53

4 months ago

4.6.54

4 months ago

4.6.59

4 months ago

4.6.57

4 months ago

4.6.58

4 months ago

2.4.21

5 months ago

2.4.20

5 months ago

2.4.23

5 months ago

2.4.22

5 months ago

4.9.73

3 months ago

4.9.72

3 months ago

4.9.74

3 months ago

4.5.32

5 months ago

4.5.33

5 months ago

4.5.31

5 months ago

4.5.36

5 months ago

4.5.37

5 months ago

4.5.34

5 months ago

4.5.35

5 months ago

4.5.38

5 months ago

4.5.39

5 months ago

5.14.89

3 months ago

4.11.76

3 months ago

4.11.75

3 months ago

3.5.31

5 months ago

3.5.30

5 months ago

4.7.70

3 months ago

4.7.71

3 months ago

4.7.72

3 months ago

6.14.89

3 months ago

4.5.40

5 months ago

4.7.68

4 months ago

4.5.41

5 months ago

4.5.42

4 months ago

4.7.69

4 months ago

4.13.80

3 months ago

4.13.81

3 months ago

4.13.82

3 months ago

2.4.16

5 months ago

2.3.16

5 months ago

2.3.13

6 months ago

2.3.15

6 months ago

2.3.14

6 months ago

2.3.12

6 months ago

2.3.11

6 months ago

2.3.10

6 months ago

2.2.10

6 months ago

2.2.9

6 months ago

2.2.8

6 months ago

1.2.8

6 months ago

1.2.7

6 months ago

1.2.6

6 months ago

1.2.5

6 months ago

1.2.4

6 months ago