1 |
3a515b92
|
cagy
|
# assign-symbols [](http://badge.fury.io/js/assign-symbols)
|
2 |
|
|
|
3 |
|
|
> Assign the enumerable es6 Symbol properties from an object (or objects) to the first object passed on the arguments. Can be used as a supplement to other extend, assign or merge methods as a polyfill for the Symbols part of the es6 Object.assign method.
|
4 |
|
|
|
5 |
|
|
From the [Mozilla Developer docs for Symbol](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol):
|
6 |
|
|
|
7 |
|
|
> A symbol is a unique and immutable data type and may be used as an identifier for object properties. The symbol object is an implicit object wrapper for the symbol primitive data type.
|
8 |
|
|
|
9 |
|
|
## Install
|
10 |
|
|
|
11 |
|
|
Install with [npm](https://www.npmjs.com/)
|
12 |
|
|
|
13 |
|
|
```sh
|
14 |
|
|
$ npm i assign-symbols --save
|
15 |
|
|
```
|
16 |
|
|
|
17 |
|
|
## Usage
|
18 |
|
|
|
19 |
|
|
```js
|
20 |
|
|
var assignSymbols = require('assign-symbols');
|
21 |
|
|
var obj = {};
|
22 |
|
|
|
23 |
|
|
var one = {};
|
24 |
|
|
var symbolOne = Symbol('aaa');
|
25 |
|
|
one[symbolOne] = 'bbb';
|
26 |
|
|
|
27 |
|
|
var two = {};
|
28 |
|
|
var symbolTwo = Symbol('ccc');
|
29 |
|
|
two[symbolTwo] = 'ddd';
|
30 |
|
|
|
31 |
|
|
assignSymbols(obj, one, two);
|
32 |
|
|
|
33 |
|
|
console.log(obj[symbolOne]);
|
34 |
|
|
//=> 'bbb'
|
35 |
|
|
console.log(obj[symbolTwo]);
|
36 |
|
|
//=> 'ddd'
|
37 |
|
|
```
|
38 |
|
|
|
39 |
|
|
## Similar projects
|
40 |
|
|
|
41 |
|
|
* [assign-deep](https://www.npmjs.com/package/assign-deep): Deeply assign the enumerable properties of source objects to a destination object. | [homepage](https://github.com/jonschlinkert/assign-deep)
|
42 |
|
|
* [clone-deep](https://www.npmjs.com/package/clone-deep): Recursively (deep) clone JavaScript native types, like Object, Array, RegExp, Date as well as primitives. | [homepage](https://github.com/jonschlinkert/clone-deep)
|
43 |
|
|
* [extend-shallow](https://www.npmjs.com/package/extend-shallow): Extend an object with the properties of additional objects. node.js/javascript util. | [homepage](https://github.com/jonschlinkert/extend-shallow)
|
44 |
|
|
* [merge-deep](https://www.npmjs.com/package/merge-deep): Recursively merge values in a javascript object. | [homepage](https://github.com/jonschlinkert/merge-deep)
|
45 |
|
|
* [mixin-deep](https://www.npmjs.com/package/mixin-deep): Deeply mix the properties of objects into the first object. Like merge-deep, but doesn't clone. | [homepage](https://github.com/jonschlinkert/mixin-deep)
|
46 |
|
|
|
47 |
|
|
## Running tests
|
48 |
|
|
|
49 |
|
|
Install dev dependencies:
|
50 |
|
|
|
51 |
|
|
```sh
|
52 |
|
|
$ npm i -d && npm test
|
53 |
|
|
```
|
54 |
|
|
|
55 |
|
|
## Contributing
|
56 |
|
|
|
57 |
|
|
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/assign-symbols/issues/new).
|
58 |
|
|
|
59 |
|
|
## Author
|
60 |
|
|
|
61 |
|
|
**Jon Schlinkert**
|
62 |
|
|
|
63 |
|
|
+ [github/jonschlinkert](https://github.com/jonschlinkert)
|
64 |
|
|
+ [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
|
65 |
|
|
|
66 |
|
|
## License
|
67 |
|
|
|
68 |
|
|
Copyright © 2015 Jon Schlinkert
|
69 |
|
|
Released under the MIT license.
|
70 |
|
|
|
71 |
|
|
***
|
72 |
|
|
|
73 |
|
|
_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on November 06, 2015._
|