type-aligned
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

Type Aligned

GitHub Workflow Status GitHub license npm semantic-release: gitmoji Twitter

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

Dependencies (0)

    Dev Dependencies (36)

    Package Sidebar

    Install

    npm i type-aligned

    Weekly Downloads

    1

    Version

    1.0.0

    License

    MIT

    Unpacked Size

    8.52 kB

    Total Files

    8

    Last publish

    Collaborators

    • aaditmshah