1.3.2 • Published 6 years ago

invariants v1.3.2

Weekly downloads
2
License
BSD-3-Clause
Repository
github
Last release
6 years ago

invariants

Used Underscore.js's way of making universal module, and used codebase of zertosh's invariants repo, to make it usable everywhere.

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

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

Install

NPM

npm install invariants

Bower

bower install invariants

Browser

<script src="invariants.js"></script>
<script>
  invariants(false, 'This will always fail');
</script>

invariants(condition, message)

const invariants = require('invariants');

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

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

Note: When process.env.NODE_ENV is not production, the message is required. If omitted, invariants 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.

1.3.2

6 years ago

1.3.0

6 years ago

1.2.3

6 years ago

1.2.2

6 years ago

1.2.1

6 years ago

1.1.0

6 years ago

1.0.0

6 years ago