Skip to content

Remove duplicates from an array of objects

License

Notifications You must be signed in to change notification settings

phalt/uniqueobj

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

uniqueObj

Given an iterable of objects, return a unique list of the objects. You define how each object is identified with a callback.

Install

npm install uniqueObj

Usage

uniqueObj([iterable,], callBack)

Takes an iterable of Object.

callBack will be called against each item in the iterable to determine it's uniqueness. Here you can hash the object, or do any logic to determine the uniqueness of it.

import uniqueObj from 'uniqueObj';

// just use the `id` value in each object to identify it
uniqueResults = uniqueObj(allResults, (obj) => obj.id);

// Do something a bit more complicated
uniqueResults = uniqueObj(allResults, myComplicatedHashFunc);

License

GNU GPL V3

About

Remove duplicates from an array of objects

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published