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

1.2.0 • Public • Published

fn-run

A typed utility library to run and debug composition functions

Installation

yarn add fn-run
npm i fn-run --save

Usage

fnRun

Functions composition are being invoked in direct order

import { fnRun } from 'fn-run';

const add = (b: number) => (a: number) => b + a;
const getString = (result: number) => console.log(`Result: ${result}`);

fnRun(add(3), add(5), getString, console.log)(1);

fnRunDebug

Run fnRun with debug output in a console.table

import { fnRunDebug } from 'fn-run';

fnRunDebug(parseFloat, console.log)('1');
// output:
// [['initial', '1'], [parseFloat, 1], [log, undefined]]

fnRace

The same as fnRun with different types declaration specifically designed for a single type for all functions. Useful to use with arrays as typescript cannot understand types from carrying function and sets unknown.

// declare generic type for an array
fnRace<Array<{id: number}>>(
    arr => arr.concat([{id: 2}]),
    arr => arr.concat([{id: 3}]),
)([{ id: 1}])

fnRunRight

fnAsyncRun

TBD

Readme

Keywords

none

Package Sidebar

Install

npm i fn-run

Weekly Downloads

0

Version

1.2.0

License

MIT

Unpacked Size

8.32 kB

Total Files

12

Last publish

Collaborators

  • elv1n