Combinable
Combinable:
object
Defined in: Core/Combinable.ts:14
Type Declaration
Section titled “Type Declaration”all:
Combinable<boolean> =allCombinable
Combines booleans with logical AND. true is the neutral element.
Combinable.any for logical OR disjunction.
Example
Section titled “Example”any:
Combinable<boolean> =anyCombinable
Combines booleans with logical OR. false is the neutral element.
Combinable.all for logical AND conjunction.
Example
Section titled “Example”array: <
A>() =>Combinable<readonlyA[]>
Combines arrays by concatenation. Empty array is the neutral element.
Type Parameters
Section titled “Type Parameters”A
Returns
Section titled “Returns”Combinable<readonly A[]>
Combinable.combineAll to flatten and concatenate nested collections.
Example
Section titled “Example”combineAll
Section titled “combineAll”combineAll: <
A>(combinable) => (items) =>A
Combines an array of elements into a single value using the Combinable’s empty as the starting point.
Type Parameters
Section titled “Type Parameters”A
Parameters
Section titled “Parameters”combinable
Section titled “combinable”Combinable<A>
Returns
Section titled “Returns”(items) => A
Combinable.struct to combine structured records.
Example
Section titled “Example”maybe: <
A>(inner) =>Combinable<Maybe<A>>
Lifts a Combinable<A> to Combinable<Maybe<A>>. None is the neutral element —
combining with None on either side returns the other value unchanged.
Two Some values combine their inner values using the inner Combinable.
Type Parameters
Section titled “Type Parameters”A
Parameters
Section titled “Parameters”Combinable<A>
Returns
Section titled “Returns”Combinable<Maybe<A>>
Combinable.combineAll to reduce collections of optional values.
Example
Section titled “Example”product
Section titled “product”product:
Combinable<number> =productCombinable
Combines numbers by multiplication. 1 is the neutral element.
Combinable.sum for additive numeric accumulation.
Example
Section titled “Example”string
Section titled “string”string:
Combinable<string> =stringCombinable
Combines strings by concatenation. Empty string is the neutral element.
Combinable.combineAll to concatenate arrays of strings.
Example
Section titled “Example”struct
Section titled “struct”struct: <
R>(fields) =>Combinable<R>
Derives a Combinable for a record of fields from field-level Combinable instances.
Type Parameters
Section titled “Type Parameters”R extends Record<string, unknown>
Parameters
Section titled “Parameters”fields
Section titled “fields”{ [K in string | number | symbol]: Combinable<R[K]> }
Returns
Section titled “Returns”Combinable<R>
Combinable.combineAll to fold arrays of structured records.
Example
Section titled “Example”sum:
Combinable<number> =sumCombinable
Combines numbers by addition. 0 is the neutral element.
Combinable.product for multiplicative numeric accumulation.