-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
25 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Sort unique [![Build Status](https://travis-ci.org/Bluefire2/sort-unique.svg?branch=master)](https://travis-ci.org/Bluefire2/sort-unique) [![Coverage Status](https://coveralls.io/repos/github/Bluefire2/sort-unique/badge.svg?branch=master)](https://coveralls.io/github/Bluefire2/sort-unique?branch=master) | ||
|
||
Sort unique is a package that sorts an array and removes all duplicate elements (without modifying the original array). | ||
|
||
### Installation | ||
You can download and install this package from NPM with `npm i -S sort-unique`. | ||
|
||
### `require('sort-unique')(array[, compare])` | ||
Sorts an array and removes all duplicates. | ||
|
||
* `array`: the array to process | ||
* `compare`: a function that compares two items in the array, returning `1` for greater than, `0` for equal, and `-1` for less than. | ||
|
||
If `compare` is unspecified, it will default to | ||
```javascript | ||
(a, b) => { | ||
if (a > b) { | ||
return 1; | ||
} else if (a < b) { | ||
return -1; | ||
} else { | ||
return 0; | ||
} | ||
}; | ||
``` |