@simplesmiler/thru

v1.0.1
Type-safe operator for chaining
chaining typescript types typed

@simplesmiler/thru

Version Documentation

Type-safe operator for chaining

  • Allows function calls to follow the data flow instead of being nested
  • Does not require pre-chain wrapping and post-chain unwrapping
  • Does not require explicit-er types than usual
  • Promotes code minification due to tree shaking and name mangling

Inspired by:

Install

npm install @simplesmiler/thru

Use

import { thru, tap } from '@simplesmiler/thru';
import { flatten } from 'lodash/fp';

const result = [1, 2, 3]
  .map((x) => [x, x * 2])
  [thru](flatten)
  [thru]((list) => list.slice().sort((a, b) => a - b))
  [tap]((sorted) => console.log('DEBUG:', sorted)) 
  .join(', ')
  [thru]((text) => `Computed numbers: ${text}`);

License

Copyright © 2020 Denis Karabaza [email protected].

This project is ISC licensed.

npm i @simplesmiler/thru

Metadata

  • ISC
  • Whatever
  • Denis Karabaza
  • released 6/26/2020

Downloads

Maintainers