Function doAfterFactory

  • Like doAfter, but remembers whether the sync or the async route should be chosen based on the first call. This could speed up things by avoiding repeated isPromise calls.

    Example

     const incrementAfter = doAfterFactory((n) => n + 1);
    const doubleAfter = doAfterFactory((n) => n * 2);

    for (let i = 1; i <= 1_000_000; i++) {
    pipe(
    i,
    incrementAfter,
    doubleAfter,
    toArray,
    );
    }

    Returns

    Type Parameters

    • TIn

    • TOut

    Parameters

    • f: ((v: TIn) => TOut | Promise<TOut>)
        • (v: TIn): TOut | Promise<TOut>
        • Parameters

          • v: TIn

          Returns TOut | Promise<TOut>

    Returns {
        asyncDoAfter: ((promise: Promise<TIn>) => Promise<TOut>);
        doAfter: ((x: TIn | Promise<TIn>) => TOut | Promise<TOut>);
        syncDoAfter: ((value: TIn) => TOut | Promise<TOut>);
    }

    • asyncDoAfter: ((promise: Promise<TIn>) => Promise<TOut>)
        • (promise: Promise<TIn>): Promise<TOut>
        • Parameters

          • promise: Promise<TIn>

          Returns Promise<TOut>

    • doAfter: ((x: TIn | Promise<TIn>) => TOut | Promise<TOut>)
        • (x: TIn | Promise<TIn>): TOut | Promise<TOut>
        • Parameters

          • x: TIn | Promise<TIn>

          Returns TOut | Promise<TOut>

    • syncDoAfter: ((value: TIn) => TOut | Promise<TOut>)
        • (value: TIn): TOut | Promise<TOut>
        • Parameters

          • value: TIn

          Returns TOut | Promise<TOut>

Generated using TypeDoc