Socket
Socket
Sign inDemoInstall

nullthrows

Package Overview
Dependencies
0
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    nullthrows

flow typed nullthrows


Version published
Weekly downloads
4.4M
decreased by-2.51%
Maintainers
1
Install size
3.74 kB
Created
Weekly downloads
 

Package description

What is nullthrows?

The nullthrows npm package is a utility that helps in asserting that a value is neither null nor undefined. If the value is null or undefined, it throws an error, otherwise, it returns the value. This is particularly useful in TypeScript or JavaScript projects where you want to ensure that values being used in your code are not null or undefined without repeatedly checking each one manually.

What are nullthrows's main functionalities?

Assertion of non-null values

This feature allows developers to assert that a variable (e.g., 'someNullableVariable') is not null or undefined. If the variable is null or undefined, the function throws an error with a custom message, helping in debugging and ensuring data integrity.

const nullthrows = require('nullthrows');
const value = nullthrows(someNullableVariable, 'someNullableVariable should not be null');

Other packages similar to nullthrows

Readme

Source

nullthrows

Build Status

A flow typed utility that accepts value (e.g. nullthrows(value)) and throws if value is null or undefined, otherwise it returns value.

Also see invariant.

Keywords

FAQs

Last updated on 10 Dec 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