source: trip-planner-front/node_modules/object.assign/README.md@ 8d391a1

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

initial commit

  • Property mode set to 100644
File size: 3.6 KB
Line 
1#object.assign <sup>[![Version Badge][npm-version-svg]][npm-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]][npm-url]
10
11[![browser support][testling-png]][testling-url]
12
13An Object.assign shim. Invoke its "shim" method to shim Object.assign if it is unavailable.
14
15This package implements the [es-shim API](https://github.com/es-shims/api) interface. It works in an ES3-supported environment and complies with the [spec](http://www.ecma-international.org/ecma-262/6.0/#sec-object.assign). In an ES6 environment, it will also work properly with `Symbol`s.
16
17Takes a minimum of 2 arguments: `target` and `source`.
18Takes a variable sized list of source arguments - at least 1, as many as you want.
19Throws a TypeError if the `target` argument is `null` or `undefined`.
20
21Most common usage:
22```js
23var assign = require('object.assign').getPolyfill(); // returns native method if compliant
24 /* or */
25var assign = require('object.assign/polyfill')(); // returns native method if compliant
26```
27
28## Example
29
30```js
31var assert = require('assert');
32
33// Multiple sources!
34var target = { a: true };
35var source1 = { b: true };
36var source2 = { c: true };
37var sourceN = { n: true };
38
39var expected = {
40 a: true,
41 b: true,
42 c: true,
43 n: true
44};
45
46assign(target, source1, source2, sourceN);
47assert.deepEqual(target, expected); // AWESOME!
48```
49
50```js
51var target = {
52 a: true,
53 b: true,
54 c: true
55};
56var source1 = {
57 c: false,
58 d: false
59};
60var sourceN = {
61 e: false
62};
63
64var assigned = assign(target, source1, sourceN);
65assert.equal(target, assigned); // returns the target object
66assert.deepEqual(assigned, {
67 a: true,
68 b: true,
69 c: false,
70 d: false,
71 e: false
72});
73```
74
75```js
76/* when Object.assign is not present */
77delete Object.assign;
78var shimmedAssign = require('object.assign').shim();
79 /* or */
80var shimmedAssign = require('object.assign/shim')();
81
82assert.equal(shimmedAssign, assign);
83
84var target = {
85 a: true,
86 b: true,
87 c: true
88};
89var source = {
90 c: false,
91 d: false,
92 e: false
93};
94
95var assigned = assign(target, source);
96assert.deepEqual(Object.assign(target, source), assign(target, source));
97```
98
99```js
100/* when Object.assign is present */
101var shimmedAssign = require('object.assign').shim();
102assert.equal(shimmedAssign, Object.assign);
103
104var target = {
105 a: true,
106 b: true,
107 c: true
108};
109var source = {
110 c: false,
111 d: false,
112 e: false
113};
114
115assert.deepEqual(Object.assign(target, source), assign(target, source));
116```
117
118## Tests
119Simply clone the repo, `npm install`, and run `npm test`
120
121[npm-url]: https://npmjs.org/package/object.assign
122[npm-version-svg]: http://versionbadg.es/ljharb/object.assign.svg
123[travis-svg]: https://travis-ci.org/ljharb/object.assign.svg
124[travis-url]: https://travis-ci.org/ljharb/object.assign
125[deps-svg]: https://david-dm.org/ljharb/object.assign.svg?theme=shields.io
126[deps-url]: https://david-dm.org/ljharb/object.assign
127[dev-deps-svg]: https://david-dm.org/ljharb/object.assign/dev-status.svg?theme=shields.io
128[dev-deps-url]: https://david-dm.org/ljharb/object.assign#info=devDependencies
129[testling-png]: https://ci.testling.com/ljharb/object.assign.png
130[testling-url]: https://ci.testling.com/ljharb/object.assign
131[npm-badge-png]: https://nodei.co/npm/object.assign.png?downloads=true&stars=true
132[license-image]: http://img.shields.io/npm/l/object.assign.svg
133[license-url]: LICENSE
134[downloads-image]: http://img.shields.io/npm/dm/object.assign.svg
135[downloads-url]: http://npm-stat.com/charts.html?package=object.assign
Note: See TracBrowser for help on using the repository browser.