https://github.com/hanford/array-dedupe
remove duplicated instances from an array by object key values
https://github.com/hanford/array-dedupe
Last synced: 22 days ago
JSON representation
remove duplicated instances from an array by object key values
- Host: GitHub
- URL: https://github.com/hanford/array-dedupe
- Owner: hanford
- Created: 2017-06-06T18:40:47.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2017-06-19T17:30:42.000Z (almost 8 years ago)
- Last Synced: 2025-03-22T15:50:02.567Z (about 1 month ago)
- Language: JavaScript
- Size: 6.84 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# array-dedupe
> remove duplicate items from an array of objects
## Install
```
$ npm install --save array-dedupe
```## Usage
```js
const Dedupe = require('array-dedupe')// Remove duplicates from an array, with a specified list of keys
const arr =[
{name: 'jack', age: 23},
{name: 'joe', age: 21},
{name: 'ben', age: 23},
...
]Dedupe(arr, ['age'])
//=> [{name: 'jack', age: 23}, {name: 'joe', age: 21}]
```## API
### DeDupe(input, keys)
Returns a filtered array.
#### input
Type: `Array`
#### keys
Type: `Array` (optional)
N length array of keys to validate against, if not passed in the library will validate every key
## License
MIT © [Jack Hanford](https://jackhanford.com)