mcpField
B
better-all

better-all

github.com/casper-studios開発15245 回インストール8 週間前に更新
リポジトリ

better-all について

better-all は、タスク間の依存関係を宣言して実行順序を調整する TypeScript ライブラリです。依存段階を手作業で組み立てずに並列実行したい開発者向けです。

主な機能

  1. 01タスク依存関係のインライン宣言
  2. 02並列実行の自動最適化
  3. 03結果型の推論

活用シーン

  1. 01独立したデータ取得の並列実行
  2. 02複数段階の処理における依存タスクの実行

インストール

コマンドをコピーしてターミナルで実行します。

$npx skills add https://github.com/casper-studios/casper-marketplace --skill better-all

インストール後、Claude Code で/better-allを入力して読み込まれたか確認します。

同梱ファイルreferences/dag-patterns.md

詳細

ドキュメント

注:このライブラリはまだ DeepWiki または Context7 にインデックスされていません。

better-all ライブラリ

better-all は、依存関係を自動的に最適化する Promise.all を提供します。どのタスクを並列実行できるかを手動で分析する代わりに、タスク内で依存関係を宣言するだけで、実行が自動的に最適化されます。

インストール

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),
});

型推論

タスクの戻り値の型に基づいて、結果の型がすべて推論されます。

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 }

参考資料

  • 複雑な DAG パターンについては、dag-patterns.md を参照してください。

コメント