Contentful Personalization & Analytics
    Preparing search index...

    Manages a list of interceptors and provides a way to run them in sequence.

    Interceptors are executed in insertion order. Each interceptor receives the result of the previous interceptor (or the initial input for the first one) and may return a new value synchronously or asynchronously.

    This class snapshots the current interceptor list at invocation time so additions/removals during run do not affect the in-flight execution.

    const mgr = new InterceptorManager<number>();
    const id = mgr.add((n) => n + 1);
    const final = await mgr.run(1); // 2
    mgr.remove(id);

    Type Parameters

    • T

      The value type processed by the interceptors.

    Index

    Constructors

    Methods

    Constructors

    Methods

    • Run all interceptors in sequence on an input value and return the final result.

      Supports both sync and async interceptors; the return type is always Promise<T> for consistency.

      Parameters

      • input: T

        The initial value to pass to the first interceptor.

      Returns Promise<T>

      A promise resolving to the final value after all interceptors have run.

      May rethrow any error thrown by an interceptor.

      The interceptor list is snapshotted at invocation time; changes to the registry during execution do not affect the running sequence.

      const result = await manager.run(initial);