source: trip-planner-front/node_modules/define-properties/README.md@ b738035

Last change on this file since b738035 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 2.7 KB
RevLine 
[6a3a178]1#define-properties <sup>[![Version Badge][npm-version-svg]][package-url]</sup>
2
3[![Build Status][travis-svg]][travis-url]
4[![dependency status][deps-svg]][deps-url]
5[![dev dependency status][dev-deps-svg]][dev-deps-url]
6[![License][license-image]][license-url]
7[![Downloads][downloads-image]][downloads-url]
8
9[![npm badge][npm-badge-png]][package-url]
10
11[![browser support][testling-svg]][testling-url]
12
13Define multiple non-enumerable properties at once. Uses `Object.defineProperty` when available; falls back to standard assignment in older engines.
14Existing properties are not overridden. Accepts a map of property names to a predicate that, when true, force-overrides.
15
16## Example
17
18```js
19var define = require('define-properties');
20var assert = require('assert');
21
22var obj = define({ a: 1, b: 2 }, {
23 a: 10,
24 b: 20,
25 c: 30
26});
27assert(obj.a === 1);
28assert(obj.b === 2);
29assert(obj.c === 30);
30if (define.supportsDescriptors) {
31 assert.deepEqual(Object.keys(obj), ['a', 'b']);
32 assert.deepEqual(Object.getOwnPropertyDescriptor(obj, 'c'), {
33 configurable: true,
34 enumerable: false,
35 value: 30,
36 writable: false
37 });
38}
39```
40
41Then, with predicates:
42```js
43var define = require('define-properties');
44var assert = require('assert');
45
46var obj = define({ a: 1, b: 2, c: 3 }, {
47 a: 10,
48 b: 20,
49 c: 30
50}, {
51 a: function () { return false; },
52 b: function () { return true; }
53});
54assert(obj.a === 1);
55assert(obj.b === 20);
56assert(obj.c === 3);
57if (define.supportsDescriptors) {
58 assert.deepEqual(Object.keys(obj), ['a', 'c']);
59 assert.deepEqual(Object.getOwnPropertyDescriptor(obj, 'b'), {
60 configurable: true,
61 enumerable: false,
62 value: 20,
63 writable: false
64 });
65}
66```
67
68## Tests
69Simply clone the repo, `npm install`, and run `npm test`
70
71[package-url]: https://npmjs.org/package/define-properties
72[npm-version-svg]: http://versionbadg.es/ljharb/define-properties.svg
73[travis-svg]: https://travis-ci.org/ljharb/define-properties.svg
74[travis-url]: https://travis-ci.org/ljharb/define-properties
75[deps-svg]: https://david-dm.org/ljharb/define-properties.svg
76[deps-url]: https://david-dm.org/ljharb/define-properties
77[dev-deps-svg]: https://david-dm.org/ljharb/define-properties/dev-status.svg
78[dev-deps-url]: https://david-dm.org/ljharb/define-properties#info=devDependencies
79[testling-svg]: https://ci.testling.com/ljharb/define-properties.png
80[testling-url]: https://ci.testling.com/ljharb/define-properties
81[npm-badge-png]: https://nodei.co/npm/define-properties.png?downloads=true&stars=true
82[license-image]: http://img.shields.io/npm/l/define-properties.svg
83[license-url]: LICENSE
84[downloads-image]: http://img.shields.io/npm/dm/define-properties.svg
85[downloads-url]: http://npm-stat.com/charts.html?package=define-properties
86
Note: See TracBrowser for help on using the repository browser.