Switch case for actions


stars 🌟issues ⚠️updated 🛠created 🐣size 🏋️‍♀️
Minified + gzip package size for @action-land/match in KB



A switch case for actions.


npm i @action-land/match


Exposes a single match() function that —

  1. Accepts two arguments — default and spec.
  2. default is a function that accepts the action and can return anything.
  3. spec is an object where key is action.type and value is a function.
  4. On a successful match of action.type the corresponding function is called with the action.value.
import {action} from '@action-land/core'
import {match} from '@action-land/match'

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

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

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.