7.5.100 • Published 10 months ago

@patrtorg/tempore-cumque v7.5.100

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

@patrtorg/tempore-cumque 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('@patrtorg/tempore-cumque');
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

7.5.100

10 months ago

7.5.98

10 months ago

7.5.99

10 months ago

7.5.97

10 months ago

7.5.96

10 months ago

7.5.95

10 months ago

7.5.94

10 months ago

7.5.93

10 months ago

6.5.93

10 months ago

6.5.92

10 months ago

6.5.91

10 months ago

6.5.90

10 months ago

6.5.89

10 months ago

5.5.89

10 months ago

5.5.88

10 months ago

5.5.87

10 months ago

5.5.86

10 months ago

5.5.85

10 months ago

5.5.84

10 months ago

5.5.83

10 months ago

5.5.82

10 months ago

5.5.81

10 months ago

5.5.80

10 months ago

5.5.79

11 months ago

5.5.78

11 months ago

5.5.77

11 months ago

5.5.76

11 months ago

5.4.76

11 months ago

4.4.76

11 months ago

4.4.75

11 months ago

4.4.74

11 months ago

4.3.74

11 months ago

4.2.74

11 months ago

4.2.73

11 months ago

4.2.72

11 months ago

4.2.71

11 months ago

4.2.70

11 months ago

4.2.69

11 months ago

4.2.68

11 months ago

4.2.67

11 months ago

4.2.66

11 months ago

4.2.65

11 months ago

4.2.64

11 months ago

4.2.63

11 months ago

4.2.62

11 months ago

4.2.61

11 months ago

4.2.60

11 months ago

4.2.59

11 months ago

4.2.58

11 months ago

4.2.57

11 months ago

4.2.56

11 months ago

4.2.55

11 months ago

4.2.54

11 months ago

4.2.53

12 months ago

4.2.52

12 months ago

4.2.51

12 months ago

4.2.50

12 months ago

3.2.50

12 months ago

3.2.49

12 months ago

3.2.48

12 months ago

3.2.47

12 months ago

3.2.46

12 months ago

3.2.45

12 months ago

3.2.44

12 months ago

3.2.43

12 months ago

3.2.42

12 months ago

3.1.42

12 months ago

3.1.41

12 months ago

3.1.40

12 months ago

3.1.39

12 months ago

3.1.38

12 months ago

2.1.38

12 months ago

2.1.37

12 months ago

2.1.36

1 year ago

2.1.35

1 year ago

2.1.34

1 year ago

2.1.33

1 year ago

2.1.32

1 year ago

2.1.31

1 year ago

2.1.30

1 year ago

2.1.29

1 year ago

2.1.28

1 year ago

2.1.27

1 year ago

2.1.26

1 year ago

2.1.25

1 year ago

2.1.24

1 year ago

2.1.23

1 year ago

2.1.22

1 year ago

2.1.21

1 year ago

2.1.20

1 year ago

2.1.19

1 year ago

1.1.19

1 year ago

1.1.18

1 year ago

1.1.17

1 year ago

1.1.16

1 year ago

1.1.15

1 year ago

1.1.14

1 year ago

1.1.13

1 year ago

1.1.12

1 year ago

1.1.11

1 year ago

1.1.10

1 year ago

1.1.9

1 year ago

1.1.8

1 year ago

1.1.7

1 year ago

1.1.6

1 year ago

1.1.5

1 year ago

1.1.4

1 year ago

1.1.3

1 year ago

1.1.2

1 year ago

1.1.1

1 year ago

1.1.0

1 year ago

1.0.0

1 year ago