use-pipe-ts
TypeScript icon, indicating that this package has built-in type declarations

2.0.3 • Public • Published

use-pipe-ts

npm build publish Libraries.io dependency status for latest release Bundlephobia npm

Pipe-based useCallback react hook

Getting started

$ npm i use-pipe-ts

Overview

export function usePipe(...fns) {
  return useCallback(
    pipe(...fns.map((fn) => (typeof fn === 'function' ? fn : subst(...fn)))),
    fns.flat()
  )
}

function subst(fn, ...subs) {
  return (...args) => fn(...subs, ...args)
}

Usage

See test

Readme

Keywords

Package Sidebar

Install

npm i use-pipe-ts

Weekly Downloads

18

Version

2.0.3

License

MIT

Unpacked Size

17.7 kB

Total Files

10

Last publish

Collaborators

  • iyegoroff