AsyncStack Class

    Package: @esfx/async-stack

    An asynchronous Stack.

    Declaration
    export declare class AsyncStack<T> 

    Constructors

    constructor(iterable)

    Initializes a new instance of the AsyncStack class.

    Declaration
    constructor(iterable?: Iterable<T | PromiseLike<T>>);
    Parameters
    iterable
    Iterable<T | PromiseLike<T>>

    An optional iterable of values or promises.

    Properties

    done

    Gets a value indicating whether the stack has ended and there are no more items available.

    Declaration
    get done(): boolean;
    Property Value
    boolean

    readable

    Gets a value indicating whether items can be read from the stack.

    Declaration
    get readable(): boolean;
    Property Value
    boolean

    size

    Gets the number of entries in the stack. When positive, indicates the number of entries available to get. When negative, indicates the number of requests waiting to be fulfilled.

    Declaration
    get size(): number;
    Property Value
    number

    writable

    Gets a value indicating whether new items can be added to the stack.

    Declaration
    get writable(): boolean;
    Property Value
    boolean

    Methods

    doneReading()

    Blocks attempts to read from the stack until it is empty. Available items in the stack can still be read until the stack is empty.

    Declaration
    doneReading(): void;
    Returns
    void

    doneWriting()

    Blocks attempts to write to the stack. Pending requests in the stack can still be resolved until the stack is empty.

    Declaration
    doneWriting(): void;
    Returns
    void

    end()

    Blocks future attempts to read or write from the stack. Available items in the stack can still be read until the stack is empty. Pending reads from the stack are rejected with a CancelError.

    Declaration
    end(): void;
    Returns
    void

    pop(cancelable)

    Removes and returns a Promise for the top value of the stack. If the stack is empty, returns a Promise for the next value to be pushed on to the stack.

    Declaration
    pop(cancelable?: Cancelable): Promise<T>;
    Parameters
    cancelable
    Cancelable

    A Cancelable used to cancel the request.

    Returns
    Promise<T>

    push(this)

    Adds a value to the top of the stack. If the stack is empty but has a pending pop request, the value will be popped and the request fulfilled.

    Declaration
    push(this: AsyncStack<void>): void;
    Parameters
    this
    AsyncStack<void>

    Returns
    void

    push(value)

    Adds a value to the top of the stack. If the stack is empty but has a pending pop request, the value will be popped and the request fulfilled.

    Declaration
    push(value: T | PromiseLike<T>): void;
    Parameters
    value
    T | PromiseLike<T>

    A value or promise to add to the stack.

    Returns
    void

    Generated by DocFX