0.0.4 • Published 3 years ago

filter-predicates v0.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

filter-predicates

A collection of useful functions to throw into Array.filter().

Installation

npm install filter-predicates or yarn add filter-predicates.

What's available?

import { filterFalsy, filterNull, filterNaN, filterTruthy, filterUndefined } from "filter-predicates";

const testArray = [true, false, 1, 0, -1, null, undefined, NaN];

testArray.filter(filterFalsy); // [true, 1, -1]

testArray.filter(filterNull); // [true, false, 1, 0, -1, undefined, NaN]

testArray.filter(filterNaN); // [true, false, 1, 0, -1, null, undefined]

testArray.filter(filterTruthy); // [false, 0, null, undefined, NaN]

testArray.filter(filterUndefined); // [true, false, 1, 0, -1, null, NaN]

But why though?

Honestly I just got tired of explaining what Array.filter(_ => _) was for. Figured this would be easier in the future.

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago