New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

or-throw

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

or-throw

Returns the value if truthy or throws an error.

latest
Source
npmnpm
Version
2.1.0
Version published
Maintainers
1
Created
Source

or-throw

Returns the value if truthy or throws an error.

import { orThrow } from 'or-throw';

let foo = null;

orThrow(foo) // throws `new Error()`
orThrow(foo, 'error message') // throws `new Error('error message')`

foo = 1

orThrow(foo) // returns 1
import { orThrowDeferred } from 'or-throw';

let foo = null;

orThrowDeferred(foo) // throws `new Error()` after a setTimeout with delay set to 0
orThrowDeferred(foo, 'error message') // throws `new Error('error message')` after a setTimeout with delay set to 0

foo = 1

orThrowDeferred(foo) // returns 1

Install

You can get or-throw via npm.

npm i or-throw

FAQs

Package last updated on 10 Sep 2023

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