node-filter-async
TypeScript icon, indicating that this package has built-in type declarations

3.0.0 • Public • Published

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';
  });
})();

Readme

Keywords

Package Sidebar

Install

npm i node-filter-async

Weekly Downloads

12,278

Version

3.0.0

License

MIT

Unpacked Size

4.53 kB

Total Files

6

Last publish

Collaborators

  • mgenware