Typed functional pipe and compose for TypeScript
npm install @philiprehberger/pipeTyped functional pipe and compose for TypeScript
npm install @philiprehberger/pipe
import { pipe, pipeline, pipeAsync } from '@philiprehberger/pipe';
const result = pipe(" Hello ", s => s.trim(), s => s.split(" "));
// string[] — fully inferred
const transform = pipeline(s => s.trim(), s => s.toLowerCase());
transform(" HELLO "); // "hello"
const data = await pipeAsync(userId, fetchUser, extractProfile, validate);
import { compose } from '@philiprehberger/pipe';
const format = compose(
(s: string) => `[${s}]`,
(s: string) => s.toUpperCase(),
(s: string) => s.trim(),
);
format(" hello "); // "[HELLO]"
| Function | Description |
|---|---|
pipe(value, ...fns) | Data-first pipeline, returns final result |
compose(...fns) | Right-to-left function composition |
pipeline(...fns) | Left-to-right composition, returns reusable function |
pipeAsync(value, ...fns) | Async-aware pipeline with await between steps |
npm install
npm run build
npm test
If you find this project useful: