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

if-else-throw

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

if-else-throw

If X, return Y, else throw Z.

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.4K
decreased by-9.08%
Maintainers
1
Weekly downloads
 
Created
Source

if-else-throw

If X, return Y, else throw Z.

X can be a boolean or a function.

Installation

npm install if-else-throw --save

Usage

const ifElseThrow = require('if-else-throw')
let value

value = []
value = ifElseThrow(
  Array.isArray(value), // The boolean condition (in this case, true)
  value, // The value returned if true
  new TypeError('Not an array') // The error thrown if false
) // []

let value = 'totally not an array'
value = ifElseThrow(
  val => Array.isArray(val), // Instead of a boolean, can use a function
  value,
  new TypeError('Not an array')
) // Uncaught TypeError

Keywords

FAQs

Package last updated on 28 Nov 2017

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