Task map where keys are task names.
Configuration options, including cancellation, concurrency, and errorMode.
errorMode: "reject" (default): rejects with an AutoExecutionError carrying partialResults.errorMode: "resolve": resolves with { results, error } containing partial results and the error.A cancellable handle resolving to task results by key (reject mode),
or { results, error } (resolve mode).
const handle = auto(
{
config: [[], async () => ({ baseUrl: "/api" })],
user: [["config"], async (results, token) => {
await token.sleep(5);
return { id: 1, url: `${results.config.baseUrl}/users/1` };
}],
posts: [["user"], async (results) => {
return [`post-of-${results.user.id}`];
}],
},
{ concurrency: 2, errorMode: "reject" },
);
const result = await handle;
// { config: { baseUrl: "/api" }, user: { ... }, posts: ["post-of-1"] }
Executes a dependency graph of async tasks.
Each task can be:
(results, token) => Promise<value>[dependencies, taskFn] where results is strongly typed by dependenciesTask map where keys are task names.
Optionaloptions: AutoRejectOptions<TResults>Configuration options, including cancellation, concurrency, and errorMode.
errorMode: "reject" (default): rejects with an AutoExecutionError carrying partialResults.errorMode: "resolve": resolves with { results, error } containing partial results and the error.A cancellable handle resolving to task results by key (reject mode),
or { results, error } (resolve mode).
const handle = auto(
{
config: [[], async () => ({ baseUrl: "/api" })],
user: [["config"], async (results, token) => {
await token.sleep(5);
return { id: 1, url: `${results.config.baseUrl}/users/1` };
}],
posts: [["user"], async (results) => {
return [`post-of-${results.user.id}`];
}],
},
{ concurrency: 2, errorMode: "reject" },
);
const result = await handle;
// { config: { baseUrl: "/api" }, user: { ... }, posts: ["post-of-1"] }
Executes a dependency graph of async tasks.
Each task can be:
(results, token) => Promise<value>[dependencies, taskFn]whereresultsis strongly typed by dependencies