@bitbite/filtered-list
v1.0.2
Published
filter a list of items
Downloads
432
Readme
FilteredList
define a set of assertion methods paired with logical operators to filter a list of items.
install
npm i @bitbite/filtered-list --save
usage
import { FilteredList, And, Or, Not } from "@bitbite/filtered-list";
const filteredList = new FilteredList<number>([1,2,3,4,5])
const lt2 = (num: number) => num < 2;
const lg4 = (num: number) => num > 4;
const lt2Orlg4 = Or<number>(lt2, lg4);
const filtered = filteredList.assert(lt2Orlg4) // [1, 5]
memoization
import { Memoized } from "@bitbite/filtered-list";
const memSum = Memoized(sum, () => hits++ )
memSum(1,2,3) // initial invocation
memSum(1,2,3) // from memo (1)
memSum(1,2,3) // from memo (2)