1.1.2 • Published 2 years ago

functional-tools v1.1.2

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Functional Tools

Fully typed utility functions to write Typescript in a more functional style

Installation

npm i --save functional-tools
yarn add functional-tools

Basic Example

Evaluate

import { evaluate } from "./evaluate";

const startsWithH = (x: string) => x[0] === "h";

const hasAComma = (x: string) => x.includes(",");

const result = evaluate("hello, world", startsWithH, hasAComma);

console.log(result);
// true

Pipeline Function

import { pipeline } from "functional-tools";

const append = (x: string) => (y: string) => y + x;

const capitalize = (x: string) => x.toUpperCase();

const removeWhitespace = (x: string) => x.replace(/ /g, "");

const helloWorld = pipeline("  hello", append(", world! "), capitalize, removeWhitespace);

console.log(helloWorld);
// "HELLO,WORLD!"
1.1.1

2 years ago

1.1.2

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago