Gamla
gamla
is a functional programming library for Javascript/Typescript.
Installation
nodejs: npm install gamla
deno: import { pipe } from "https://deno.land/x/gamla/src/index.ts";
Docs
This library allows you to write in typescript/javascript using composition.
It has two main advantages over similar libs:
- It supports mixing async and sync functions
- It keeps the type information, so you still get type safety when programming in pipelines.
A basic example:
const histogram = pipe(
split(""),
filter(complement(anyjuxt(equals(" "), equals("'")))),
// The function here is async.
reduce((x, y) => Promise.resolve({ ...x, [y]: (x[y] || 0) + 1 }), () => ({})),
sideEffect(console.log),
);
await histogram("let's see how many times each letter appears here");