match-action
TypeScript icon, indicating that this package has built-in type declarations

1.0.6 • Public • Published

Match Action Build Status

A switch case for actions.

Usage

Exposes a single match() function that —

  1. Accepts two arguments — default and spec.
  2. default is a function that accepts the action.value and can return anything.
  3. spec is an object where key is action.type and value is a function.
import {action} from 'action-types'
import {match} from 'match-action'

const fn = match(i => i, {
  inc: i => i + 1,
  dec: i => i - 1
})

fn(action('inc', 10)) // returns 11

Package Sidebar

Install

npm i match-action

Weekly Downloads

1

Version

1.0.6

License

ISC

Unpacked Size

120 kB

Total Files

7

Last publish

Collaborators

  • tusharmathur