@super-zuo/zuo-task
v0.0.1
Published
Task orchestration. by super-zuo
Maintainers
Readme
📦 安装
npm install @super-zuo/zuo-task
# 或
yarn add @super-zuo/zuo-task
import { task } from '@super-zuo/zuo-task';
//🔥 自动透传上一个结果!函数可选接收 prevResult 作为参数。
const results = await task()
.add(() => login('user', 'pass')) // → { token: 'xxx' }
.add(({ token }) => fetchProfile(token)) // ← receives prev result
.add(profile => saveToCache(profile)) // ← receives prev result
.run(); // [loginRes, profileRes, cacheRes]
console.log(results[1].name); // "Alice"
//🚀 Parallel Execution(并行:独立任务加速)
const [user, posts, stats] = await task()
.add(() => fetchUser())
.add(() => fetchPosts())
.add(() => fetchStats())
.parallel(); // Runs all at once!
