Gathering detailed insights and metrics for p-filter
Gathering detailed insights and metrics for p-filter
Gathering detailed insights and metrics for p-filter
Gathering detailed insights and metrics for p-filter
conventional-commits-filter
Filter out reverted commits parsed by conventional-commits-parser.
filter-obj
Filter object keys and values into a new object
os-filter-obj
Filter an array of objects to a specific OS
through2-filter
A through2 to create an Array.prototype.filter analog for streams.
npm install p-filter
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
73 Stars
22 Commits
8 Forks
7 Watching
1 Branches
5 Contributors
Updated on 20 Nov 2024
JavaScript (66.45%)
TypeScript (33.55%)
Cumulative downloads
Total Downloads
Last day
7.6%
1,022,962
Compared to previous day
Last week
5.9%
5,297,066
Compared to previous week
Last month
17.4%
20,981,329
Compared to previous month
Last year
-13.9%
206,398,220
Compared to previous year
Filter promises concurrently
Useful when you need to run promise-returning & async functions multiple times with different inputs concurrently and get a filtered down result.
1npm install p-filter
1import pFilter from 'p-filter'; 2import getWeather from 'get-weather'; // Not a real module 3 4const places = [ 5 getCapital('Norway').then(info => info.name), 6 'Bangkok, Thailand', 7 'Berlin, Germany', 8 'Tokyo, Japan', 9]; 10 11const filterer = async place => { 12 const weather = await getWeather(place); 13 return weather.temperature > 30; 14}; 15 16const result = await pFilter(places, filterer); 17 18console.log(result); 19//=> ['Bangkok, Thailand']
Returns a Promise
that is fulfilled when all promises in input
and ones returned from filterer
are fulfilled, or rejects if any of the promises reject. The fulfilled value is an Array
of the fulfilled values returned from filterer
in input
order.
Type: Iterable<Promise<unknown> | unknown>
Iterated over concurrently in the filterer
function.
Type: Function
The filterer function that decides whether an element should be included into result. Expected to return boolean | Promise<boolean>
.
Type: object
See the p-map
options.
Type: number
Default: Infinity
Minimum: 1
The number of concurrently pending promises returned by filterer
.
Returns an async iterable that iterates over the promises in iterable
and ones returned from filterer
concurrently, calling filterer
for each element.
1import {pFilterIterable} from 'p-filter'; 2import getWeather from 'get-weather'; // Not a real module 3 4async function * getPlaces() { 5 const name = await getCapital('Norway'); 6 7 yield name; 8 yield 'Bangkok, Thailand'; 9 yield 'Berlin, Germany'; 10 yield 'Tokyo, Japan'; 11} 12 13const places = getPlaces(); 14 15const filterer = async place => { 16 const weather = await getWeather(place); 17 return weather.temperature > 30; 18}; 19 20for await (const element of pFilterIterable(places, filterer)) { 21 console.log(element); 22} 23//=> ['Bangkok, Thailand']
Type: Iterable<Promise<unknown> | unknown>
Iterated over concurrently in the filterer
function.
Type: Function
The filterer function that decides whether an element should be included into result. Expected to return boolean | Promise<boolean>
.
Type: object
See the p-map
options.
Type: number
Default: Infinity
Minimum: 1
The number of concurrently pending promises returned by filterer
.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
security policy file detected
Details
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
Found 6/22 approved changesets -- score normalized to 2
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More