<TBase extends new (...args: ReadonlyArray<any>) => any>(
klass: TBase
): TBase & PipeableConstructorReturns a subclass of the provided class that adds the standard pipe
method.
When to use
Use to add pipe support to an existing class without extending a base class or modifying its prototype.
Details
The original constructor and instance members are preserved, and the added
method delegates to pipeArguments.
export const const Mixin: <
TBase extends new (
...args: ReadonlyArray<any>
) => any
>(
klass: TBase
) => TBase & PipeableConstructor
Returns a subclass of the provided class that adds the standard pipe
method.
When to use
Use to add pipe support to an existing class without extending a base class
or modifying its prototype.
Details
The original constructor and instance members are preserved, and the added
method delegates to pipeArguments.
Mixin = <function (type parameter) TBase in <TBase extends new (...args: ReadonlyArray<any>) => any>(klass: TBase): TBase & PipeableConstructorTBase extends new(...args: readonly any[]args: interface ReadonlyArray<T>ReadonlyArray<any>) => any>(
klass: TBase extends new (...args: ReadonlyArray<any>) => anyklass: function (type parameter) TBase in <TBase extends new (...args: ReadonlyArray<any>) => any>(klass: TBase): TBase & PipeableConstructorTBase
): function (type parameter) TBase in <TBase extends new (...args: ReadonlyArray<any>) => any>(klass: TBase): TBase & PipeableConstructorTBase & PipeableConstructor => (class extends klass: TBase extends new (...args: ReadonlyArray<any>) => anyklass {
function (Anonymous class).pipe(): unknownpipe() {
return const pipeArguments: <this>(self: this, args: IArguments) => unknownApplies a pipe method's variadic arguments to an initial value from left
to right.
When to use
Use to implement a custom .pipe(...) method from JavaScript's arguments
object.
Details
This helper is intended for implementing Pipeable.pipe methods that
receive JavaScript's arguments object. With no functions it returns the
original value; otherwise it feeds each result into the next function.
Example (Implementing a pipe method)
import { Pipeable } from "effect"
class NumberBox {
constructor(readonly value: number) {}
pipe(..._fns: ReadonlyArray<(value: number) => number>): number {
return Pipeable.pipeArguments(this.value, arguments) as number
}
}
const result = new NumberBox(5).pipe(
(n) => n + 2,
(n) => n * 3
)
console.log(result) // 21
pipeArguments(this, function (local var) arguments: IArgumentsarguments)
}
})