MCPcopy Index your code
hub / github.com/zertosh/invariant

github.com/zertosh/invariant @v2.2.4

Chat with this repo
repository ↗ · DeepWiki ↗ · release v2.2.4 ↗ · + Follow
2 symbols 5 edges 6 files 0 documented · 0% 64 cross-repo links updated 4y ago★ 1,23214 open issues
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

invariant

Build Status

A mirror of Facebook's invariant (e.g. React, flux).

A way to provide descriptive errors in development but generic errors in production.

Install

With npm do:

npm install invariant

invariant(condition, message)

var invariant = require('invariant');

invariant(someTruthyVal, 'This will not throw');
// No errors

invariant(someFalseyVal, 'This will throw an error with this message');
// Error: Invariant Violation: This will throw an error with this message

Note: When process.env.NODE_ENV is not production, the message is required. If omitted, invariant will throw regardless of the truthiness of the condition. When process.env.NODE_ENV is production, the message is optional – so they can be minified away.

Browser

When used with browserify, it'll use browser.js (instead of invariant.js) and the envify transform will inline the value of process.env.NODE_ENV.

Node

The node version is optimized around the performance implications of accessing process.env. The value of process.env.NODE_ENV is cached, and repeatedly used instead of reading process.env. See Server rendering is slower with npm react #812

Core symbols most depended-on inside this repo

Shape

Function 2

Languages

TypeScript100%

Modules by API surface

invariant.js1 symbols
browser.js1 symbols

For agents

$ claude mcp add invariant \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page