array-filter-unique
v3.1.0
Published
JavaScript array.filter() compatible unique filter
Downloads
133
Maintainers
Readme
array-filter-unique
JavaScript array.filter() compatible unique filter
As all unique libraries are used as a function and not within the easily stackable and immutable arr.format() style I made my own.
Install
Node.js:
npm install array-filter-unique
Deno:
import {/* ... */} from "https://deno.land/x/array_filter_unique/mod.ts";
Usage
import { arrayFilterUnique } from "array-filter-unique";
['a', 'a', 'b', 'c']
.filter(arrayFilterUnique());
//=> ['a', 'b', 'c']
[{name: 'Alice', …}, {name: 'Peter', …}, {name: 'Alice', …}}]
.filter(arrayFilterUnique(o => o.name));
//=> [{name: 'Alice', …}, {name: 'Peter', …}]
Migrate from v2 to v3
-const arrayFilterUnique = require('array-filter-unique');
+import {arrayFilterUnique} from 'array-filter-unique';
someArray.filter(arrayFilterUnique());