Prelude API
    Preparing search index...
    • Creates a transformer that maps each value using the provided function.

      Type Parameters

      • T
      • R

      Parameters

      • f: F<T, R>

        Function to apply to each value, receiving the value, its index, and worker number

      • options: { concurrency?: number; preserveOrder?: boolean; signal?: AbortSignal } = {}

        Configuration options

        • Optionalconcurrency?: number

          Number of concurrent operations (default: 1)

        • OptionalpreserveOrder?: boolean

          Whether to preserve the original order (default: true)

        • Optionalsignal?: AbortSignal

          Aborting makes the transformer throw signal.reason and stop pulling from the source; a mapping already in flight is left to settle on its own and its result is dropped

      Returns Transformer<T, Awaited<R>>

      A transformer function that yields the mapped values

      Applies a mapping function to each value in an async iterable, with support for concurrent processing and order preservation.

      // Serial mapping (default)
      const doubled = await G.pipe(
      G.ofIterable([1, 2, 3]),
      G.map(x => x * 2),
      G.array
      ); // [2, 4, 6]

      // Concurrent mapping with preserved order
      const results = await G.pipe(
      G.ofIterable([1, 2, 3, 4, 5]),
      G.map(async x => {
      await sleep(100);
      return x * 2;
      }, { concurrency: 3 }),
      G.array
      ); // [2, 4, 6, 8, 10]