Getting Started
Prerequisites
Section titled “Prerequisites”- Node.js v18 or higher
- A package manager: npm, bun, yarn, or pnpm
Installation
Section titled “Installation”Each package is published independently under the @thuum scope. Install only the packages you need:
# npmnpm install @thuum/pipernpm install @thuum/decornpm install @thuum/promisingnpm install @thuum/transportnpm install @thuum/channels @thuum/transport
# bunbun add @thuum/piperQuick Examples
Section titled “Quick Examples”Pipe a value through transformations
Section titled “Pipe a value through transformations”import { pipe } from "@thuum/piper";
const { value } = pipe(1) .pipe((x) => x + 1) .pipe((x) => x * 2);
console.log(value); // 4Safe error handling
Section titled “Safe error handling”import { attempt } from "@thuum/decor";
const safeParse = attempt(JSON.parse);const result = safeParse("invalid json");
if ("error" in result) { console.error("Parse failed:", result.error);} else { console.log("Parsed:", result.value);}Sequential async execution
Section titled “Sequential async execution”import { createContext } from "@thuum/promising";
const ctx = createContext({ watch: (event) => console.log(`[${event.type}] ${event.name}`),});
ctx.run("first", async () => await fetchFirst());ctx.run("second", async () => await fetchSecond());// "second" always waits for "first" to completeMessage channels
Section titled “Message channels”import { createMessageChannel } from "@thuum/channels";import { createTransport } from "@thuum/transport";
const channel = createMessageChannel({ schemas: { greeting: { message: { parse: (data) => ({ value: data }) } }, }, transport: createTransport({ type: "window-custom-event", namespace: "app" }),});
channel.receiver.on("greeting", { ondata: ({ value }) => console.log(value),});
channel.sender.send("greeting", { text: "Hello!" });Development
Section titled “Development”To work on the Thuum monorepo itself:
git clone https://github.com/jalepi/thuum.gitcd thuumbun installbun run buildbun run test