match-map
v1.0.3
Published
Match against the keys in a map
Downloads
7
Readme
Installation
yarn add match-map
Or:
npm install match-map --save
Usage
import matchMap from 'match-map'
Or:
const matchMap = require('match-map')
Then:
const Processing = Symbol()
const Successful = Symbol()
const Error = Symbol()
const state = Successful
const statusMessage = matchMap(state)([
[Loading, 'Your task is processing'],
[Successful, 'Your task was successful!'],
[Error, 'There was an error with your task :(']
])
Alternatively:
const statusMessage = matchMap(state)(new Map([
[Loading, 'Your task is processing'],
[Successful, 'Your task was successful!'],
[Error, 'There was an error with your task :(']
]))