@f/to-middleware

Convert a function redux style middleware.

Usage no npm install needed!

<script type="module">
  import fToMiddleware from 'https://cdn.skypack.dev/@f/to-middleware';
</script>

README

to-middleware

Build status Git tag NPM version Code style

Convert a function redux style middleware.

Installation

$ npm install @f/to-middleware

Usage

var toMiddleware = require('@f/to-middleware')
var bind = require('@f/bind-middleware')

var addOne = bind([toMiddleware(add)])

addOne(1) // => 2

function add (v) {
  return v + 1
}

API

toMiddleware(fn, type)

  • fn - unary function to use in middleware
  • type - type to match on - if matched payload is passed to fn - if not present action is passed to fn

Returns:

License

MIT