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

@el3um4s/match

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@el3um4s/match

Alternative to JavaScript’s switch statement with a functional twist

  • 0.0.5
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
12
increased by140%
Maintainers
1
Weekly downloads
 
Created
Source

@el3um4s/match

Alternative to JavaScript’s switch statement with a functional twist

Based on Alternative to JavaScript’s switch statement with a functional twist

NPM: @el3um4s/match

Install and use the package

To use the package in a project:

npm i @el3um4s/match

and then in a file:

import match from "@el3um4s/match";

const handleShape = (shape, w) => area(shape,w);

function area (type = "Circle", width = 2) {
  return match(type)
          .on(type => type.toLowerCase() === "circle", () => {
              return Math.PI * (width / 2) ** 2;
            })
          .on(type => type.toLowerCase() === "square", () => width ** 2)
          .otherwise(() => 0);
};

handleShape("Square", 3);

Keywords

FAQs

Package last updated on 26 Jun 2022

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

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