Composes given functions (in the mathematical sense).
Unlike flow and pipe, functions passed to compose are applied (called) from last to first.
const f = (x: number): number => x * x;
const g = (x: number): string => x.toFixed();
const h = (x: string): boolean => x === '4';
compose(
h, // 3. true
g, // 2. 4
f, // 1. 2
)(2) // 4. true
// gives same result as
h(g(f(2))) // true
Composes given functions (in the mathematical sense).
Unlike flow and pipe, functions passed to compose are applied (called) from last to first.
const f = (x: number): number => x * x;
const g = (x: number): string => x.toFixed();
const h = (x: string): boolean => x === '4';
compose(
h, // 3. true
g, // 2. 4
f, // 1. 2
)(2) // 4. true
// gives same result as
h(g(f(2))) // true
Composes given functions (in the mathematical sense).
Unlike flow and pipe, functions passed to compose are applied (called) from last to first.
const f = (x: number): number => x * x;
const g = (x: number): string => x.toFixed();
const h = (x: string): boolean => x === '4';
compose(
h, // 3. true
g, // 2. 4
f, // 1. 2
)(2) // 4. true
// gives same result as
h(g(f(2))) // true
Composes given functions (in the mathematical sense).
Unlike flow and pipe, functions passed to compose are applied (called) from last to first.
const f = (x: number): number => x * x;
const g = (x: number): string => x.toFixed();
const h = (x: string): boolean => x === '4';
compose(
h, // 3. true
g, // 2. 4
f, // 1. 2
)(2) // 4. true
// gives same result as
h(g(f(2))) // true
Composes given functions (in the mathematical sense).
Unlike flow and pipe, functions passed to compose are applied (called) from last to first.
const f = (x: number): number => x * x;
const g = (x: number): string => x.toFixed();
const h = (x: string): boolean => x === '4';
compose(
h, // 3. true
g, // 2. 4
f, // 1. 2
)(2) // 4. true
// gives same result as
h(g(f(2))) // true
Composes given functions (in the mathematical sense).
Unlike flow and pipe, functions passed to compose are applied (called) from last to first.
const f = (x: number): number => x * x;
const g = (x: number): string => x.toFixed();
const h = (x: string): boolean => x === '4';
compose(
h, // 3. true
g, // 2. 4
f, // 1. 2
)(2) // 4. true
// gives same result as
h(g(f(2))) // true
Composes given functions (in the mathematical sense).
Unlike flow and pipe, functions passed to compose are applied (called) from last to first.
const f = (x: number): number => x * x;
const g = (x: number): string => x.toFixed();
const h = (x: string): boolean => x === '4';
compose(
h, // 3. true
g, // 2. 4
f, // 1. 2
)(2) // 4. true
// gives same result as
h(g(f(2))) // true
Composes given functions (in the mathematical sense).
Unlike flow and pipe, functions passed to compose are applied (called) from last to first.
const f = (x: number): number => x * x;
const g = (x: number): string => x.toFixed();
const h = (x: string): boolean => x === '4';
compose(
h, // 3. true
g, // 2. 4
f, // 1. 2
)(2) // 4. true
// gives same result as
h(g(f(2))) // true
Composes given functions (in the mathematical sense).
Unlike flow and pipe, functions passed to compose are applied (called) from last to first.
const f = (x: number): number => x * x;
const g = (x: number): string => x.toFixed();
const h = (x: string): boolean => x === '4';
compose(
h, // 3. true
g, // 2. 4
f, // 1. 2
)(2) // 4. true
// gives same result as
h(g(f(2))) // true
Composes given functions (in the mathematical sense).
Unlike flow and pipe, functions passed to compose are applied (called) from last to first.
const f = (x: number): number => x * x;
const g = (x: number): string => x.toFixed();
const h = (x: string): boolean => x === '4';
compose(
h, // 3. true
g, // 2. 4
f, // 1. 2
)(2) // 4. true
// gives same result as
h(g(f(2))) // true
Transforms the given function of two arguments from "tuple curried" format to curried one.
const addPair = ([a, b]: [number, number]) => a + b;
opt(1) // Some(1)
.map(
curryTuple(addPair)(4) // same as `(a => b => a + b)(4)`
) // Some(5)
Transforms the given function of three arguments from "tuple curried" format to curried one.
Transforms the given function of four arguments from "tuple curried" format to curried one.
Transforms the given function of five arguments from "tuple curried" format to curried one.
Same as Opt.flatMap, but also supports arrays.
Same as Opt.flatMap, but also supports arrays.
Takes functions and builds a function which consecutively calls each given function with a result from a previous one. Similar to Opt.pipe, but doesn't take input directly, instead returns a function which can be called repeatedly with different inputs.
flow( // 1. 63
add1, // 2. 64
Math.sqrt, // 3. 8
)(63), // 4. 8
// gives same result as
Math.sqrt(add1(63)) // 8
const f = flow(add1, Math.sqrt); // (_: number) => number
f(63); // 8
f(3); // 2
Takes functions and builds a function which consecutively calls each given function with a result from a previous one. Similar to Opt.pipe, but doesn't take input directly, instead returns a function which can be called repeatedly with different inputs.
flow( // 1. 63
add1, // 2. 64
Math.sqrt, // 3. 8
)(63), // 4. 8
// gives same result as
Math.sqrt(add1(63)) // 8
const f = flow(add1, Math.sqrt); // (_: number) => number
f(63); // 8
f(3); // 2
Takes functions and builds a function which consecutively calls each given function with a result from a previous one. Similar to Opt.pipe, but doesn't take input directly, instead returns a function which can be called repeatedly with different inputs.
flow( // 1. 63
add1, // 2. 64
Math.sqrt, // 3. 8
)(63), // 4. 8
// gives same result as
Math.sqrt(add1(63)) // 8
const f = flow(add1, Math.sqrt); // (_: number) => number
f(63); // 8
f(3); // 2
Takes functions and builds a function which consecutively calls each given function with a result from a previous one. Similar to Opt.pipe, but doesn't take input directly, instead returns a function which can be called repeatedly with different inputs.
flow( // 1. 63
add1, // 2. 64
Math.sqrt, // 3. 8
)(63), // 4. 8
// gives same result as
Math.sqrt(add1(63)) // 8
const f = flow(add1, Math.sqrt); // (_: number) => number
f(63); // 8
f(3); // 2
Takes functions and builds a function which consecutively calls each given function with a result from a previous one. Similar to Opt.pipe, but doesn't take input directly, instead returns a function which can be called repeatedly with different inputs.
flow( // 1. 63
add1, // 2. 64
Math.sqrt, // 3. 8
)(63), // 4. 8
// gives same result as
Math.sqrt(add1(63)) // 8
const f = flow(add1, Math.sqrt); // (_: number) => number
f(63); // 8
f(3); // 2
Takes functions and builds a function which consecutively calls each given function with a result from a previous one. Similar to Opt.pipe, but doesn't take input directly, instead returns a function which can be called repeatedly with different inputs.
flow( // 1. 63
add1, // 2. 64
Math.sqrt, // 3. 8
)(63), // 4. 8
// gives same result as
Math.sqrt(add1(63)) // 8
const f = flow(add1, Math.sqrt); // (_: number) => number
f(63); // 8
f(3); // 2
Takes functions and builds a function which consecutively calls each given function with a result from a previous one. Similar to Opt.pipe, but doesn't take input directly, instead returns a function which can be called repeatedly with different inputs.
flow( // 1. 63
add1, // 2. 64
Math.sqrt, // 3. 8
)(63), // 4. 8
// gives same result as
Math.sqrt(add1(63)) // 8
const f = flow(add1, Math.sqrt); // (_: number) => number
f(63); // 8
f(3); // 2
Takes functions and builds a function which consecutively calls each given function with a result from a previous one. Similar to Opt.pipe, but doesn't take input directly, instead returns a function which can be called repeatedly with different inputs.
flow( // 1. 63
add1, // 2. 64
Math.sqrt, // 3. 8
)(63), // 4. 8
// gives same result as
Math.sqrt(add1(63)) // 8
const f = flow(add1, Math.sqrt); // (_: number) => number
f(63); // 8
f(3); // 2
Takes functions and builds a function which consecutively calls each given function with a result from a previous one. Similar to Opt.pipe, but doesn't take input directly, instead returns a function which can be called repeatedly with different inputs.
flow( // 1. 63
add1, // 2. 64
Math.sqrt, // 3. 8
)(63), // 4. 8
// gives same result as
Math.sqrt(add1(63)) // 8
const f = flow(add1, Math.sqrt); // (_: number) => number
f(63); // 8
f(3); // 2
Takes functions and builds a function which consecutively calls each given function with a result from a previous one. Similar to Opt.pipe, but doesn't take input directly, instead returns a function which can be called repeatedly with different inputs.
flow( // 1. 63
add1, // 2. 64
Math.sqrt, // 3. 8
)(63), // 4. 8
// gives same result as
Math.sqrt(add1(63)) // 8
const f = flow(add1, Math.sqrt); // (_: number) => number
f(63); // 8
f(3); // 2
Identity function.
id(1) // 1
id(null) // null
Same as Opt.print, but supports arbitrary argument types.
Transforms the given function of two arguments from curried format to "tuple curried" which can be used with Opt.zip.
const sub = (x: number) => (y: number) => x - y;
opt(4) // Some(4)
.zip(opt(1)) // Some([4, 1])
.map(uncurryTuple(sub)) // Some(3)
Transforms the given function of three arguments from curried format to "tuple curried" which can be used with Opt.zip3.
Transforms the given function of four arguments from curried format to "tuple curried" which can be used with Opt.zip4.
Transforms the given function of five arguments from curried format to "tuple curried" which can be used with Opt.zip5.
Generated using TypeDoc
Single global instance of None.