array-where
v1.0.1
Published
A transpilation to array.filter() functionality, but with a clearer linguistic intent.
Downloads
5
Maintainers
Readme
Background
I often mix up the filtering of arrays because I put in what I want to filter out into the predicate, because that's what filtering should be.
So this library is purely to add a better named extension method that just forwards the parameters to the this.filter()
so you don't need to worry about mixing it up again.
For further reading on the underlying .filter()
functionality, see the MDN docs.
Install
Using NPM:
npm install array-where
Then, it can be imported with:
import 'array-where'
Usage
For flat values:
[1, 2, 3].where(x => x > 1)
For objects:
[{ value: 1 }, { value: 2 }, { value: 3 },].where(item => item.value > 1)