@vitkuz/vitkuz-pipe
v1.0.2
Published
A type-safe utility for piping functions.
Maintainers
Readme
@vitkuz/vitkuz-pipe
A type-safe utility for piping functions in TypeScript and JavaScript.
Installation
npm install @vitkuz/vitkuz-pipeUsage
The pipe function allows you to compose functions from left to right. It strictly types the input and output of each function, ensuring type safety throughout the pipeline.
import { pipe } from '@vitkuz/vitkuz-pipe';
const addOne = (n: number) => n + 1;
const double = (n: number) => n * 2;
const toString = (n: number) => n.toString();
const result = pipe(
addOne,
double,
toString
)(5);
console.log(result); // "12"Features
- Type Safety: strict typing for up to 6 piped functions (and fallback for more).
- Runtime Validation: ensures that all arguments passed to
pipeare functions. - Zero Dependencies: lightweight and focused.
License
ISC
