func-toolkit
v1.1.2-1
Published
func-toolkit provides functional utilities.
Downloads
4
Maintainers
Readme
func-toolkit
The func-toolkit includes several useful function combinator and utilities. The compinator provided by the func-toolkit can use any iterable object. func-toolkit provides all of these without any dependencies.
How to use
Most examples can find on test code.
Example: all
import { all } from "func-toolkit";
const data = [2, 10, 4, 6];
const isAllEven = all(data, element => element % 2 == 0);
Example: andThen
import { andThen } from "func-toolkit";
function f(x) {
return 2 * x;
}
function g(x) {
return x + 2;
}
const fg = andThen(f, g);
fg(3); // 8
Example: compose
import { compose } from "func-toolkit";
function f(x) {
return 2 * x;
}
function g(x) {
return x + 2;
}
const gf = compose(
f,
g
);
gf(4); // 12