source: trip-planner-front/node_modules/is-data-descriptor/README.md@ 1ad8e64

Last change on this file since 1ad8e64 was e29cc2e, checked in by Ema <ema_spirova@…>, 3 years ago

primeNG components

  • Property mode set to 100644
File size: 3.2 KB
Line 
1# is-data-descriptor [![NPM version](https://img.shields.io/npm/v/is-data-descriptor.svg)](https://www.npmjs.com/package/is-data-descriptor) [![Build Status](https://img.shields.io/travis/jonschlinkert/is-data-descriptor.svg)](https://travis-ci.org/jonschlinkert/is-data-descriptor)
2
3> Returns true if a value has the characteristics of a valid JavaScript data descriptor.
4
5## Install
6
7Install with [npm](https://www.npmjs.com/):
8
9```sh
10$ npm i is-data-descriptor --save
11```
12
13## Usage
14
15```js
16var isDataDesc = require('is-data-descriptor');
17```
18
19## Examples
20
21`true` when the descriptor has valid properties with valid values.
22
23```js
24// `value` can be anything
25isDataDesc({value: 'foo'})
26isDataDesc({value: function() {}})
27isDataDesc({value: true})
28//=> true
29```
30
31`false` when not an object
32
33```js
34isDataDesc('a')
35//=> false
36isDataDesc(null)
37//=> false
38isDataDesc([])
39//=> false
40```
41
42`false` when the object has invalid properties
43
44```js
45isDataDesc({value: 'foo', bar: 'baz'})
46//=> false
47isDataDesc({value: 'foo', bar: 'baz'})
48//=> false
49isDataDesc({value: 'foo', get: function(){}})
50//=> false
51isDataDesc({get: function(){}, value: 'foo'})
52//=> false
53```
54
55`false` when a value is not the correct type
56
57```js
58isDataDesc({value: 'foo', enumerable: 'foo'})
59//=> false
60isDataDesc({value: 'foo', configurable: 'foo'})
61//=> false
62isDataDesc({value: 'foo', writable: 'foo'})
63//=> false
64```
65
66## Valid properties
67
68The only valid data descriptor properties are the following:
69
70* `configurable` (required)
71* `enumerable` (required)
72* `value` (optional)
73* `writable` (optional)
74
75To be a valid data descriptor, either `value` or `writable` must be defined.
76
77**Invalid properties**
78
79A descriptor may have additional _invalid_ properties (an error will **not** be thrown).
80
81```js
82var foo = {};
83
84Object.defineProperty(foo, 'bar', {
85 enumerable: true,
86 whatever: 'blah', // invalid, but doesn't cause an error
87 get: function() {
88 return 'baz';
89 }
90});
91
92console.log(foo.bar);
93//=> 'baz'
94```
95
96## Related projects
97
98* [is-accessor-descriptor](https://www.npmjs.com/package/is-accessor-descriptor): Returns true if a value has the characteristics of a valid JavaScript accessor descriptor. | [homepage](https://github.com/jonschlinkert/is-accessor-descriptor)
99* [is-descriptor](https://www.npmjs.com/package/is-descriptor): Returns true if a value has the characteristics of a valid JavaScript descriptor. Works for… [more](https://www.npmjs.com/package/is-descriptor) | [homepage](https://github.com/jonschlinkert/is-descriptor)
100* [isobject](https://www.npmjs.com/package/isobject): Returns true if the value is an object and not an array or null. | [homepage](https://github.com/jonschlinkert/isobject)
101
102## Running tests
103
104Install dev dependencies:
105
106```sh
107$ npm i -d && npm test
108```
109
110## Contributing
111
112Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/is-data-descriptor/issues/new).
113
114## Author
115
116**Jon Schlinkert**
117
118* [github/jonschlinkert](https://github.com/jonschlinkert)
119* [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
120
121## License
122
123Copyright © 2015 [Jon Schlinkert](https://github.com/jonschlinkert)
124Released under the MIT license.
125
126***
127
128_This file was generated by [verb](https://github.com/verbose/verb) on December 28, 2015._
Note: See TracBrowser for help on using the repository browser.