JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 13697
  • Score
    100M100P100Q131909F
  • License MIT

Filter array elements with Promises

Package Exports

  • node-filter-async

Readme

node-filter-async

Build Status npm version Node.js Version

Filter array elements with Promises, zero dependencies, written in TypeScript.

Installation

npm i node-filter-async

Usage

API

filterAsync<T>(
  // The array to be filtered.
  array: T[],
  // The async filter callback.
  callback: (value: T, index: number) => Promise<boolean>,
): Promise<T[]>;

Example:

import filterAsync from 'node-filter-async';

(async () => {
  const results = await filterAsync(someArray, async (value, index) => {
    console.log(`filtering [${index}]: ${value}`);
    return (await asyncFunc(value)) === 'blablabla';
  });
})();