root / HServer / 00.Server / 00.Program / node_modules / object-assign / readme.md
이력 | 보기 | 이력해설 | 다운로드 (1.16 KB)
1 | 39 | HKM | # object-assign [](https://travis-ci.org/sindresorhus/object-assign) |
---|---|---|---|
2 | |||
3 | > ES6 [`Object.assign()`](http://www.2ality.com/2014/01/object-assign.html) ponyfill |
||
4 | |||
5 | > Ponyfill: A polyfill that doesn't overwrite the native method |
||
6 | |||
7 | |||
8 | ## Install |
||
9 | |||
10 | ```sh |
||
11 | $ npm install --save object-assign |
||
12 | ``` |
||
13 | |||
14 | |||
15 | ## Usage |
||
16 | |||
17 | ```js |
||
18 | var objectAssign = require('object-assign'); |
||
19 | |||
20 | objectAssign({foo: 0}, {bar: 1}); |
||
21 | //=> {foo: 0, bar: 1} |
||
22 | |||
23 | // multiple sources |
||
24 | objectAssign({foo: 0}, {bar: 1}, {baz: 2}); |
||
25 | //=> {foo: 0, bar: 1, baz: 2} |
||
26 | |||
27 | // overwrites equal keys |
||
28 | objectAssign({foo: 0}, {foo: 1}, {foo: 2}); |
||
29 | //=> {foo: 2} |
||
30 | |||
31 | // ignores null and undefined sources |
||
32 | objectAssign({foo: 0}, null, {bar: 1}, undefined); |
||
33 | //=> {foo: 0, bar: 1} |
||
34 | ``` |
||
35 | |||
36 | |||
37 | ## API |
||
38 | |||
39 | ### objectAssign(target, source, [source, ...]) |
||
40 | |||
41 | Assigns enumerable own properties of `source` objects to the `target` object and returns the `target` object. Additional `source` objects will overwrite previous ones. |
||
42 | |||
43 | |||
44 | ## Resources |
||
45 | |||
46 | - [ES6 spec - Object.assign](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.assign) |
||
47 | |||
48 | |||
49 | ## License |
||
50 | |||
51 | MIT © [Sindre Sorhus](http://sindresorhus.com) |