source: imaps-frontend/node_modules/define-data-property/README.md

main
Last change on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 2.4 KB
Line 
1# define-data-property <sup>[![Version Badge][npm-version-svg]][package-url]</sup>
2
3[![github actions][actions-image]][actions-url]
4[![coverage][codecov-image]][codecov-url]
5[![License][license-image]][license-url]
6[![Downloads][downloads-image]][downloads-url]
7
8[![npm badge][npm-badge-png]][package-url]
9
10Define a data property on an object. Will fall back to assignment in an engine without descriptors.
11
12The three `non*` argument can also be passed `null`, which will use the existing state if available.
13
14The `loose` argument will mean that if you attempt to set a non-normal data property, in an environment without descriptor support, it will fall back to normal assignment.
15
16## Usage
17
18```javascript
19var defineDataProperty = require('define-data-property');
20var assert = require('assert');
21
22var obj = {};
23defineDataProperty(obj, 'key', 'value');
24defineDataProperty(
25 obj,
26 'key2',
27 'value',
28 true, // nonEnumerable, optional
29 false, // nonWritable, optional
30 true, // nonConfigurable, optional
31 false // loose, optional
32);
33
34assert.deepEqual(
35 Object.getOwnPropertyDescriptors(obj),
36 {
37 key: {
38 configurable: true,
39 enumerable: true,
40 value: 'value',
41 writable: true,
42 },
43 key2: {
44 configurable: false,
45 enumerable: false,
46 value: 'value',
47 writable: true,
48 },
49 }
50);
51```
52
53[package-url]: https://npmjs.org/package/define-data-property
54[npm-version-svg]: https://versionbadg.es/ljharb/define-data-property.svg
55[deps-svg]: https://david-dm.org/ljharb/define-data-property.svg
56[deps-url]: https://david-dm.org/ljharb/define-data-property
57[dev-deps-svg]: https://david-dm.org/ljharb/define-data-property/dev-status.svg
58[dev-deps-url]: https://david-dm.org/ljharb/define-data-property#info=devDependencies
59[npm-badge-png]: https://nodei.co/npm/define-data-property.png?downloads=true&stars=true
60[license-image]: https://img.shields.io/npm/l/define-data-property.svg
61[license-url]: LICENSE
62[downloads-image]: https://img.shields.io/npm/dm/define-data-property.svg
63[downloads-url]: https://npm-stat.com/charts.html?package=define-data-property
64[codecov-image]: https://codecov.io/gh/ljharb/define-data-property/branch/main/graphs/badge.svg
65[codecov-url]: https://app.codecov.io/gh/ljharb/define-data-property/
66[actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/ljharb/define-data-property
67[actions-url]: https://github.com/ljharb/define-data-property/actions
Note: See TracBrowser for help on using the repository browser.