Help us improve
Share bugs, ideas, or general feedback.
From stack-patterns
Optimizes Promise.all with better-all library's automatic DAG-based dependency resolution and full TypeScript type inference for parallelizing complex async operations.
npx claudepluginhub casper-studios/casper-marketplace --plugin stack-patternsHow this skill is triggered — by the user, by Claude, or both
Slash command
/stack-patterns:better-allThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
- GitHub Repository: https://github.com/shuding/better-all
Types async/await functions, Promise chains, concurrent patterns (Promise.all, allSettled, race), error handling, Result patterns, and retry logic in TypeScript.
Decomposes large changes, migrations, or multi-issue fixes into parallel work packages executed via independent subagents with quality gates to prevent conflicts.
Implements practical async error handling in TypeScript using fp-ts TaskEither for clean composable pipelines instead of nested try/catch, with fetch API examples.
Share bugs, ideas, or general feedback.
Note: This library is not yet indexed in DeepWiki or Context7.
better-all provides Promise.all with automatic dependency optimization. Instead of manually analyzing which tasks can run in parallel, tasks declare dependencies inline and execution is automatically optimized.
pnpm add better-all
import { all } from "better-all";
const results = await all({
// Independent tasks run in parallel
fetchUser: () => fetchUser(userId),
fetchPosts: () => fetchPosts(userId),
// Dependent task waits automatically
combined: async (ctx) => {
const user = await ctx.$.fetchUser;
const posts = await ctx.$.fetchPosts;
return { user, posts };
},
});
// results.fetchUser, results.fetchPosts, results.combined all typed
// Manual approach - error-prone
const [user, posts] = await Promise.all([fetchUser(), fetchPosts()]);
const profile = await buildProfile(user, posts);
const [feed, stats] = await Promise.all([
buildFeed(profile, posts),
buildStats(profile),
]);
// better-all - dependencies declared, execution optimized
const results = await all({
user: () => fetchUser(),
posts: () => fetchPosts(),
profile: async (ctx) => buildProfile(await ctx.$.user, await ctx.$.posts),
feed: async (ctx) => buildFeed(await ctx.$.profile, await ctx.$.posts),
stats: async (ctx) => buildStats(await ctx.$.profile),
});
Results are fully typed based on task return types:
const results = await all({
count: () => Promise.resolve(42),
name: () => Promise.resolve("test"),
combined: async (ctx) => ({
count: await ctx.$.count,
name: await ctx.$.name,
}),
});
// TypeScript knows:
// results.count: number
// results.name: string
// results.combined: { count: number; name: string }