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

1.1.2 • Public • Published

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!"

Package Sidebar

Install

npm i functional-tools

Weekly Downloads

0

Version

1.1.2

License

MIT

Unpacked Size

2.94 kB

Total Files

3

Last publish

Collaborators

  • dmailloux