similars
Find similar objects and partial duplicates in collections
Installation
$ npm install --save similars
Usage
const similars = ; const bobs = fn: 'BOB' ln: 'DYLAN' p: 'Musician' fn: 'B' ln: 'Marley' p: 'Singer' fn: 'Bob' ln: 'Dylan' p: 'SINGER' fn: 'Bobby' ln: 'Dylan' p: 'MUSICIAN' fn: 'BOB' ln: 'MARLEY' p: 'MUSICIAN' ; // Find Bobs with the same last name (ln) and profession (p);
API
similars(collection, matcher[, onEach])
Returns a Promise
, however, processing is synchronous
- ####
collection
Required
:Array
containing objects
- ####
matcher
Required
:Function
that compares each item in the collection and returns aBoolean
- e.g.
(a, b) => a.name.toLowerCase() === b.name.toLowerCase()
- ####
onEach
Optional
:Function
that executes once for each item in thecollection
- Is good for showing progress on long running executions
License
ISC © Buster Collings