@adviser/cement - v0.0.0
    Preparing search index...

    Class ResolveSeq<T, CTX>

    Executes functions sequentially, one at a time, ensuring order of execution.

    ResolveSeq maintains a queue of functions and executes them in order, waiting for each to complete before starting the next. This is useful when you need to ensure operations happen in a specific sequence, even when multiple operations are queued concurrently.

    const seq = new ResolveSeq<number>();

    // Multiple calls are queued and executed in order
    const p1 = seq.add(() => asyncOperation1());
    const p2 = seq.add(() => asyncOperation2());
    const p3 = seq.add(() => asyncOperation3());

    // Operations execute sequentially: op1 -> op2 -> op3
    await Promise.all([p1, p2, p3]);

    Type Parameters

    • T

      The return type of the functions

    • CTX extends NonNullable<object> = object

      Optional context type passed to each function

    Index

    Constructors

    Properties

    ctx?: CTX
    _seqFutures: ResolveSeqItem<CTX, T, unknown>[] = []
    _flushWaiting: Future<void, void>[] = []

    Methods

    • Resets the sequence (currently a no-op).

      Returns void

    • Returns a promise that resolves when all currently queued items complete.

      Returns Promise<void>

      A promise that resolves when the queue is empty

    • Internal

      Internal method to process items in the queue sequentially.

      Parameters

      • Optionalitem: ResolveSeqItem<CTX, T, T | Promise<T>>

      Returns Promise<void>

    • Adds a function to the sequence queue for sequential execution.

      The function will be executed after all previously queued functions complete. Returns a promise that resolves with the function's result.

      Type Parameters

      • R

      Parameters

      • fn: (c: CTX) => R

        The function to execute

      • Optionalid: number

        Optional identifier for tracking

      Returns R

      A promise that resolves with the function's result