1.0.3 • Published 8 years ago
match-map v1.0.3
Installation
yarn add match-mapOr:
npm install match-map --saveUsage
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 :(']
]))