Home Reference Source Repository
import {Flow} from 'monad-ts/src/flow.js'
public class | source

Flow

Extends:

Monad → Flow

Indirect Implements:

Class Flow - for composing monads in a flow (pipe).

Constructor Summary

Public Constructor
public

constructor(initV: any, encapsulate: boolean)

Create an instance of class AsyncFlow.

Member Summary

Public Members
public

the instance of ErrorM.

public

flow: any

keep initial flow (pipe) value.

public

the instance of Maybe.

Method Summary

Public Methods
public

bind(f: function(v: T), v: any): Flow<T>

Chains the operations on a monadic values.

public

let(f: function(v: T)): Flow<T>

Creates branch from a flow (pipe).

public

subscribe(): T

Extract value from a flow (pipe).

Inherited Summary

From class Monad
public abstract

bind(f: MF<T, U>|D<T>, v: *): Promise<U> | Pr<U> | Error | boolean | void

Binds transformation function and underlying value to the monad.

protected

fail(e: Error | string): Error

Takes Error or string return Error.

protected

just(f: function(v: T), v: T): Pr<U>

Produces result after execution f(v).

Public Constructors

public constructor(initV: any, encapsulate: boolean) source

Create an instance of class AsyncFlow.

Params:

NameTypeAttributeDescription
initV any

initial value of new flow (pipe).

encapsulate boolean
  • optional
  • default: true

encapsulate - flag, if true then the init value will be cloned.

Public Members

public err: ErrorM source

the instance of ErrorM.

public flow: any source

keep initial flow (pipe) value.

public maybe: Maybe source

the instance of Maybe.

Public Methods

public bind(f: function(v: T), v: any): Flow<T> source

Chains the operations on a monadic values.

Override:

Monad#bind

Params:

NameTypeAttributeDescription
f function(v: T)

transformation function for a main flow value.

v any
  • optional
  • default: this.flow

underlying value for a monad.

Return:

Flow<T>

transformed by f() value v or throw Error or null.

public let(f: function(v: T)): Flow<T> source

Creates branch from a flow (pipe).

Params:

NameTypeAttributeDescription
f function(v: T)

transformation function for a main flow value.

Return:

Flow<T>

public subscribe(): T source

Extract value from a flow (pipe).

Return:

T