API Reference

Here are some of interfaces provided in the library. Full API reference will be available later.

Option[T] class for managing empty and fulfilled data easily.

declare class Option<T> implements Optionable<T> {
    static Some<T>(value: T): Option<T>;
    static None(): Option<{}>;
    
    isEmpty: boolean;
    isDefined: boolean;
    
    constructor(value?: T);
    
    getOrElse<V>(stopGap: V): T | V;
    orElse<V>(fallback: Option<V>): Option<T | V>;
    
    map<P>(func: (val: T) => P): Option<P | T>;
    flatMap<P>(func: (val: T) => Option<P>): Option<T | P>;
    coflatMap<P>(func: (val: Option<T>) => P): Option<T | P>;
    forEach(func: (val: T) => void): void;
    filter(pred: (val: T) => boolean): Option<T>;
    flatten<K>(): Option<T | K>;
    combine<P>(that: Option<P>): Option<T | P>;
    fold<S>(f: (val: T) => S, g: () => S): S;
    exists(pred: (val: T) => boolean): boolean;
    forall(pred: (val: T) => boolean): boolean;
}

Either[K, T] class for managing right/wrong data or data disjunctions.

Try[T] class for easy working with throwable functions and data they produce.

Last updated