better-all by casper-studios/casper-marketplace
npx skills add https://github.com/casper-studios/casper-marketplace --skill better-all注意:此库尚未被 DeepWiki 或 Context7 收录。
better-all 提供了具备自动依赖优化的 Promise.all。无需手动分析哪些任务可以并行运行,任务只需内联声明依赖关系,执行过程便会自动优化。
pnpm add better-all
import { all } from "better-all";
const results = await all({
// 独立任务并行运行
fetchUser: () => fetchUser(userId),
fetchPosts: () => fetchPosts(userId),
// 依赖任务自动等待
combined: async (ctx) => {
const user = await ctx.$.fetchUser;
const posts = await ctx.$.fetchPosts;
return { user, posts };
},
});
// results.fetchUser, results.fetchPosts, results.combined 均具有类型提示
// 手动方式 - 容易出错
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 - 声明依赖,优化执行
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),
});
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
结果完全根据任务返回类型进行类型推断:
const results = await all({
count: () => Promise.resolve(42),
name: () => Promise.resolve("test"),
combined: async (ctx) => ({
count: await ctx.$.count,
name: await ctx.$.name,
}),
});
// TypeScript 知道:
// results.count: number
// results.name: string
// results.combined: { count: number; name: string }
每周安装量
92
仓库
GitHub 星标数
9
首次出现
14 天前
安全审计
已安装于
cline92
github-copilot92
codex92
kimi-cli92
gemini-cli92
cursor92
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 }
Weekly Installs
92
Repository
GitHub Stars
9
First Seen
14 days ago
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
cline92
github-copilot92
codex92
kimi-cli92
gemini-cli92
cursor92
Skills CLI 使用指南:AI Agent 技能包管理器安装与管理教程
43,100 周安装