FuncType - v0.8.85
    Preparing search index...

    Interface List<A>

    A version of Functype for collection types that need iteration support. Extends FunctypeBase with Iterable protocol but without Extractable.

    interface List<A> {
        _tag: "List";
        "[iterator]": () => Iterator<A>;
        add: (item: A) => List<A>;
        ap: <B>(ff: List<(value: A) => B>) => List<B>;
        concat: (other: List<A>) => List<A>;
        filterNot: (p: (a: A) => boolean) => List<A>;
        filterType: <T extends { _tag: string }>(tag: string) => List<T & A>;
        flatMap: <B>(f: (a: A) => Iterable<B>) => List<B>;
        flatMapAsync: <B>(
            f: (a: A) => PromiseLike<Iterable<B, any, any>>,
        ) => PromiseLike<List<B>>;
        get: (index: number) => Option<A>;
        isEmpty: boolean;
        length: number;
        map: <B>(f: (a: A) => B) => List<B>;
        remove: (value: A) => List<A>;
        removeAt: (index: number) => List<A>;
        size: number;
        get head(): undefined | A;
        get headOption(): Option<A>;
        contains(value: A): boolean;
        count(p: (x: A) => boolean): number;
        drop(n: number): FunctypeCollection;
        dropRight(n: number): FunctypeCollection;
        dropWhile(p: (a: A) => boolean): FunctypeCollection;
        exists(p: (a: A) => boolean): boolean;
        filter<S>(predicate: (a: A) => a is S): List<S>;
        filter(predicate: (a: A) => unknown): List<A>;
        find(p: (a: A) => boolean): Option<A>;
        flatten<B>(): FunctypeCollection;
        fold<B>(onEmpty: () => B, onValue: (value: A) => B): B;
        foldLeft<B>(z: B): (op: (b: B, a: A) => B) => B;
        foldRight<B>(z: B): (op: (a: A, b: B) => B) => B;
        forEach(f: (a: A) => void): void;
        match<R>(patterns: { Empty: () => R; NonEmpty: (values: A[]) => R }): R;
        pipe<U extends unknown>(f: (value: A[]) => U): U;
        reduce(f: (b: A, a: A) => A): A;
        reduceRight(f: (b: A, a: A) => A): A;
        serialize(): SerializationMethods<A>;
        toArray<B = A>(): B[];
        toList(): List<A>;
        toSet(): Set<A>;
        toString(): string;
        toValue(): { _tag: "List"; value: A[] };
    }

    Type Parameters

    • A

      The element type of the collection

    Hierarchy (View Summary)

    Index

    Properties

    _tag: "List"
    "[iterator]": () => Iterator<A>
    add: (item: A) => List<A>
    ap: <B>(ff: List<(value: A) => B>) => List<B>
    concat: (other: List<A>) => List<A>
    filterNot: (p: (a: A) => boolean) => List<A>
    filterType: <T extends { _tag: string }>(tag: string) => List<T & A>
    flatMap: <B>(f: (a: A) => Iterable<B>) => List<B>
    flatMapAsync: <B>(
        f: (a: A) => PromiseLike<Iterable<B, any, any>>,
    ) => PromiseLike<List<B>>
    get: (index: number) => Option<A>
    isEmpty: boolean
    length: number
    map: <B>(f: (a: A) => B) => List<B>
    remove: (value: A) => List<A>
    removeAt: (index: number) => List<A>
    size: number

    Accessors

    • get head(): undefined | A

      Gets the first element of the collection.

      Returns undefined | A

    • get headOption(): Option<A>

      Gets the first element wrapped in Option.

      Returns Option<A>

    Methods

    • Counts elements that satisfy the predicate. For single-value containers: returns 0 or 1 For collections: returns the count of matching elements

      Parameters

      • p: (x: A) => boolean

      Returns number

    • Tests whether any element satisfies the predicate. For single-value containers: tests the single value For collections: returns true if any element matches

      Parameters

      • p: (a: A) => boolean

      Returns boolean

    • Type Parameters

      • S

      Parameters

      • predicate: (a: A) => a is S

      Returns List<S>

    • Parameters

      • predicate: (a: A) => unknown

      Returns List<A>

    • Finds the first element that satisfies the predicate. For single-value containers: returns Some(value) if predicate matches, None otherwise For collections: returns the first matching element wrapped in Option

      Parameters

      • p: (a: A) => boolean

      Returns Option<A>

    • Pattern matches over the structure, applying specific handlers for each variant

      Type Parameters

      • B

      Parameters

      • onEmpty: () => B

        Function to apply if the structure is empty or has no value

      • onValue: (value: A) => B

        Function to apply if the structure has a value

      Returns B

      The result of applying the appropriate function

    • Left-associative fold using the provided zero value and operation

      Type Parameters

      • B

      Parameters

      • z: B

        Zero/identity value

      Returns (op: (b: B, a: A) => B) => B

      A function that takes an operation to apply

    • Right-associative fold using the provided zero value and operation

      Type Parameters

      • B

      Parameters

      • z: B

        Zero/identity value

      Returns (op: (a: A, b: B) => B) => B

      A function that takes an operation to apply

    • Applies an effect function to each element. For single-value containers: applies to the value if present For collections: applies to each element

      Parameters

      • f: (a: A) => void

      Returns void

    • Pattern matches over the List, applying a handler function based on whether it's empty

      Type Parameters

      • R

      Parameters

      • patterns: { Empty: () => R; NonEmpty: (values: A[]) => R }

        Object with handler functions for Empty and NonEmpty variants

      Returns R

      The result of applying the matching handler function

    • Pipes the value through the provided function

      Type Parameters

      • U extends unknown

        The return type of the function

      Parameters

      • f: (value: A[]) => U

        The function to apply to the value

      Returns U

      The result of applying the function to the value