Socket
Socket
Sign inDemoInstall

@highhi/ifn

Package Overview
Dependencies
1
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @highhi/ifn

ifn is a library that is an alternative to the switch syntax


Version published
Weekly downloads
2
Maintainers
1
Created
Weekly downloads
 

Readme

Source

ifn

ifn is a library that is an alternative to the switch syntax.

Installation

$ npm i -S @highhi/ifn

Usage

const f = ifn([
  ['foo', 'value is string'],
  [0, 'value is number'],
  [{}, 'value is object']
  ['func', () => 'value is function']
], 'default value'); // default value is optional

console.log(f('foo'))   // value is string
console.log(f(0))       // value is number
console.log(f({}))      // value is object
console.log(f('func'))  // value is function
console.log(f([]))      // default value

It using lodash.isequal for comparison of values.

License

MIT © highhi

Keywords

FAQs

Last updated on 20 Apr 2018

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc