Socket
Socket
Sign inDemoInstall

match-ts

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

match-ts

match-ts is a cute pattern matcher that you can use when you want your code to be super cool and chained.


Version published
Maintainers
1
Created
Source

match-ts

match-ts is a cute pattern matcher that you can use when you want your code to be super cool and chained.

Get rid of those nasty if-else blocks and start matching!

examples

import match from 'match-ts';

const greet = (name?: string) =>
  match(name)
    .on(name === 'Carlos', `I'm not saying hi to you >:(`)
    .on(name != null, `hey ${name} how are you :)`)
    .otherwise('hey there friend');

const greetWithFunctionInputs = (name?: string) =>
  match(name)
    .on(n => n === 'Carlos', `I'm not saying hi to you >:(`)
    .on(
      n => n != null,
      n => `hey ${n} how are you :)`
    )
    .otherwise(n => 'hey there friend');

greet('Carlos'); // "I'm not saying hi to you >:("
greetWithFunctionInputs('David'); // "hey David how are you :)"

Never break a beautiful chain for some lame imperative logic ever again!

FAQs

Package last updated on 14 Feb 2020

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