Skip to content

akp-tools/filter-predicates

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published