type-aligned
v1.0.0
Published
library for abstract data types of type-aligned sequences
Downloads
11
Maintainers
Readme
Type Aligned
Various abstract data types of type-aligned sequences. A type-aligned sequence is a heterogeneous sequence where the types enforce the element order.
Pipeline
A pipeline is a left-to-right composition of functions.
import { tap, pipe, feed } from "type-aligned";
const length = (s: string) => s.length;
const even = (n: number) => n % 2 === 0;
const pipeline = pipe(length, pipe(even, tap()));
const morphism = feed(pipeline);
console.log(morphism("Hello World!")); // true
console.log(morphism("hello world")); // false
Composition
A composition is a right-to-left composition of functions.
import { id, compose, apply } from "type-aligned";
const length = (s: string) => s.length;
const even = (n: number) => n % 2 === 0;
const composition = compose(even, compose(length, id()));
const morphism = apply(composition);
console.log(morphism("Hello World!")); // true
console.log(morphism("hello world")); // false