🚀 Big News:Socket Has Acquired Secure Annex.Learn More →
Socket
Book a DemoSign 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

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
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