Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ts-invariant

Package Overview
Dependencies
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ts-invariant

TypeScript implementation of invariant(condition, message)

  • 0.3.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4.5M
increased by0.08%
Maintainers
1
Weekly downloads
 
Created

What is ts-invariant?

The ts-invariant package provides utility functions for asserting invariants within TypeScript applications. It is designed to throw errors when certain conditions are not met, which can be useful for catching programming errors and enforcing certain constraints at runtime.

What are ts-invariant's main functionalities?

Invariant

The invariant function is used to assert that a condition is true. If the condition is false, it will throw an error with the provided error message.

import { invariant } from 'ts-invariant';
invariant(condition, 'Expected condition to be true');

Invariant.warn

The invariant.warn function is used to log a warning message to the console. It does not throw an error.

import { invariant } from 'ts-invariant';
invariant.warn('This is a warning message');

Invariant.error

The invariant.error function is used to log an error message to the console. It does not throw an error.

import { invariant } from 'ts-invariant';
invariant.error('This is an error message');

Other packages similar to ts-invariant

Keywords

FAQs

Package last updated on 09 Apr 2019

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