Asynchronously filters an array of items: The Array.prototype.filter
function does not allow to filter an array using asynchronous predicates. However by applying the filter
function, it becomes possible to do so.
npm install @dizmo/functions-filter --save
const { filter } = require('@dizmo/functions-filter');
import { filter } from "@dizmo/functions-filter";
const even_numbers = await filter([0,1,2,3,4], (n) => new Promise(
(resolve) => setTimeout(() => resolve(n % 2 === 0))
));
const odd_numbers = await filter([0,1,2,3,4], (n) => new Promise(
(resolve) => setTimeout(() => resolve(n % 2 === 1))
));
npm run clean
npm run build
npm run -- build --no-lint --no-clean
npm run -- build --prepack
npm run -- build --prepack --no-minify
npm run lint
npm run -- lint --fix
npm run test
npm run -- test --no-lint --no-clean --no-build
npm run cover
npm run -- cover --no-lint --no-clean --no-build
npm run docs
npm publish
npm publish --access=public
© 2020 dizmo AG, Switzerland