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