1
|
# union-value [![NPM version](https://img.shields.io/npm/v/union-value.svg?style=flat)](https://www.npmjs.com/package/union-value) [![NPM monthly downloads](https://img.shields.io/npm/dm/union-value.svg?style=flat)](https://npmjs.org/package/union-value) [![NPM total downloads](https://img.shields.io/npm/dt/union-value.svg?style=flat)](https://npmjs.org/package/union-value) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/union-value.svg?style=flat&label=Travis)](https://travis-ci.org/jonschlinkert/union-value)
|
2
|
|
3
|
> Set an array of unique values as the property of an object. Supports setting deeply nested properties using using object-paths/dot notation.
|
4
|
|
5
|
## Install
|
6
|
|
7
|
Install with [npm](https://www.npmjs.com/):
|
8
|
|
9
|
```sh
|
10
|
$ npm install --save union-value
|
11
|
```
|
12
|
|
13
|
## Usage
|
14
|
|
15
|
```js
|
16
|
var union = require('union-value');
|
17
|
|
18
|
var obj = {};
|
19
|
|
20
|
union(obj, 'a.b.c', ['one', 'two']);
|
21
|
union(obj, 'a.b.c', ['three']);
|
22
|
|
23
|
console.log(obj);
|
24
|
//=> {a: {b: {c: [ 'one', 'two', 'three' ] }}}
|
25
|
```
|
26
|
|
27
|
## About
|
28
|
|
29
|
### Related projects
|
30
|
|
31
|
* [assign-value](https://www.npmjs.com/package/assign-value): Assign a value or extend a deeply nested property of an object using object path… [more](https://github.com/jonschlinkert/assign-value) | [homepage](https://github.com/jonschlinkert/assign-value "Assign a value or extend a deeply nested property of an object using object path notation.")
|
32
|
* [get-value](https://www.npmjs.com/package/get-value): Use property paths (`a.b.c`) to get a nested value from an object. | [homepage](https://github.com/jonschlinkert/get-value "Use property paths (`a.b.c`) to get a nested value from an object.")
|
33
|
* [has-value](https://www.npmjs.com/package/has-value): Returns true if a value exists, false if empty. Works with deeply nested values using… [more](https://github.com/jonschlinkert/has-value) | [homepage](https://github.com/jonschlinkert/has-value "Returns true if a value exists, false if empty. Works with deeply nested values using object paths.")
|
34
|
* [set-value](https://www.npmjs.com/package/set-value): Create nested values and any intermediaries using dot notation (`'a.b.c'`) paths. | [homepage](https://github.com/jonschlinkert/set-value "Create nested values and any intermediaries using dot notation (`'a.b.c'`) paths.")
|
35
|
* [unset-value](https://www.npmjs.com/package/unset-value): Delete nested properties from an object using dot notation. | [homepage](https://github.com/jonschlinkert/unset-value "Delete nested properties from an object using dot notation.")
|
36
|
|
37
|
### Contributing
|
38
|
|
39
|
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
|
40
|
|
41
|
### Building docs
|
42
|
|
43
|
_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_
|
44
|
|
45
|
To generate the readme, run the following command:
|
46
|
|
47
|
```sh
|
48
|
$ npm install -g verbose/verb#dev verb-generate-readme && verb
|
49
|
```
|
50
|
|
51
|
### Running tests
|
52
|
|
53
|
Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
|
54
|
|
55
|
```sh
|
56
|
$ npm install && npm test
|
57
|
```
|
58
|
|
59
|
### Author
|
60
|
|
61
|
**Jon Schlinkert**
|
62
|
|
63
|
* [github/jonschlinkert](https://github.com/jonschlinkert)
|
64
|
* [twitter/jonschlinkert](https://twitter.com/jonschlinkert)
|
65
|
|
66
|
### License
|
67
|
|
68
|
Copyright © 2017, [Jon Schlinkert](https://github.com/jonschlinkert).
|
69
|
Released under the [MIT License](LICENSE).
|
70
|
|
71
|
***
|
72
|
|
73
|
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.4.2, on February 25, 2017._
|