@dizmo/functions-filter
v1.0.5
Published
asynchronous filtering
Downloads
3
Readme
@dizmo/functions-filter
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.
Usage
Installation
npm install @dizmo/functions-filter --save
Require
const { filter } = require('@dizmo/functions-filter');
Examples
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))
));
Development
Clean
npm run clean
Build
npm run build
without linting and cleaning:
npm run -- build --no-lint --no-clean
with UMD bundling (incl. minimization):
npm run -- build --prepack
with UMD bundling (excl. minimization):
npm run -- build --prepack --no-minify
Lint
npm run lint
with auto-fixing:
npm run -- lint --fix
Test
npm run test
without linting, cleaning and (re-)building:
npm run -- test --no-lint --no-clean --no-build
Cover
npm run cover
without linting, cleaning and (re-)building:
npm run -- cover --no-lint --no-clean --no-build
Documentation
npm run docs
Publication
npm publish
initially (if public):
npm publish --access=public
Copyright
© 2020 dizmo AG, Switzerland