Function: mapBot()
mapBot<
TBot>(config):Processable<unknown[],InferBotOutput<TBot>[]>
Defined in: packages/core/src/pipeline/fan-out.ts:184
Create a step that maps a bot over an array — Array.map, for processables.
Accepts any Processable — a bot, a pipeline, a graph, a deterministic
step — and carries that processable's output type through, so the mapped
result is Item[] rather than unknown.
Array in, array out. To map part of a larger object and put the results
back, compose with a primitive that carries the original through, rather
than asking map to reshape objects too:
graph.from((src) => {
const scores = src.pipe(step((o) => o.reviews)).pipe(mapBot({ bot }));
return merge({ original: src, scores }).pipe(
step(({ original, scores }) => ({ ...original, scores }))
);
});
Type Parameters
TBot
TBot extends Processable<unknown, unknown>
The processable applied to each element; the per-item output type is inferred from it
Parameters
config
MapBotConfig & object
Configuration object with bot, parallel, and concurrency
Returns
Processable<unknown[], InferBotOutput<TBot>[]>
Processable that performs the mapping
Example
// Map over an array
const processList = pipeline(
loadItems,
mapBot({ bot: processItemBot }),
saveResults
);
// Bounded concurrency, for rate limits
const enrich = pipeline(
loadRows,
mapBot({ bot: expensiveBot, concurrency: 5 })
);
// One at a time
const sequential = mapBot({ bot: expensiveBot, parallel: false });