You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

select-case

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

select-case

A better switch case

1.0.0
latest
Source
npmnpm
Version published
Weekly downloads
41K
-11.59%
Maintainers
1
Weekly downloads
 
Created
Source

select-case

A better switch case

Installation

npm install select-case --save

Usage

import { select } from "select-case";
let fruit = 'apple'

let color = select(fruit, {
    // can be values
    banana: 'yellow',
    // or functions
    apple: () => Math.random() > 0.5 ? 'red' : 'green',
    // default case
    default: 'red'
})

Other libs

Most other libs curried or put the cases first and the selector second. I put the selector up front and the cases afterward to try and preserve the switch/case look & feel.

Dependencies

None

Dev Dependencies

None

License

MIT

Keywords

select

FAQs

Package last updated on 19 Nov 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts