Function customAdapter

  • A non-currying variant of withCustomAdapter. Takes an adapter function and returns an async iterable based on the adapter.

    Returns

    An AsyncIterable of U generated from the adapter function.

    Example

    const arrayAdapter: Adapter<undefined, number> = () => {
    let index = 0;
    const array = [1, 2, 3];
    return {
    next: () =>
    Promise.resolve(
    index < array.length
    ? { value: array[index++], done: false }
    : { value: undefined, done: true }
    ),
    };
    };
    const iterable = customAdapter(arrayAdapter);

    (async () => {
    for await (const value of iterable) {
    console.log(value); // Logs 1, 2, 3
    }
    })();

    Type Parameters

    • U

      The type of data contained in the resulting async iterable.

    Parameters

    • adapter: Adapter<undefined, U>

      The adapter function to transform the input value into an async iterable.

    Returns AsyncIterable<U>

Generated using TypeDoc