New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

functional-switch

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

functional-switch - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

2

package.json
{
"name": "functional-switch",
"version": "1.0.0",
"version": "1.0.1",
"description": "A functional implementation of switch.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -5,2 +5,35 @@ # Functional Switch

It just an idea right now. Discussion is here: https://gist.github.com/wuct/19e85b98cc7fe12a7b0a
It just an idea right now and I have not written any code, yet. Discussions are welcome!
## Installation
`npm install functional-switch --save`
## Usage
```js
import { cond, when, otherwise } from 'functional-switch'
// simple example
const isFruitOrVegetable = cond(
when('apple', 'isFruit'),
when('orange', 'isFruit'),
when('eggplant', 'isVegetable'),
otherwise('isFruit')
)
isFruitOrVegetable('apple') // isFruit
```
`when` is curried
```js
when('apple')('isFruit')
```
`when` also accepts a function or a regular expression
```js
when(/apple/)
when(str => str.includes('apple'))
```
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc