Socket
Socket
Sign inDemoInstall

invariant

Package Overview
Dependencies
2
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.1.0 to 2.1.1

19

CHANGELOG.md

@@ -0,1 +1,14 @@

2.1.1 / 2015-09-20
==================
* Use correct SPDX license.
* Test "browser.js" using browserify.
* Switch from "envify" to "loose-envify".
2.1.0 / 2015-06-03
==================
* Add "envify" as a dependency.
* Fixed license field in "package.json".
2.0.0 / 2015-02-21

@@ -10,3 +23,3 @@ ==================

* Added tests, npmignore and gitignore.
* Clarifications in README
* Clarifications in README.

@@ -16,3 +29,3 @@ 1.0.1 / 2014-09-24

* Actually include 'invariant.js'
* Actually include 'invariant.js'.

@@ -22,2 +35,2 @@ 1.0.0 / 2014-09-24

* Initial release
* Initial release.

25

package.json
{
"name": "invariant",
"version": "2.1.0",
"version": "2.1.1",
"description": "invariant",
"license": "BSD",
"keywords": [
"test"
],
"license": "BSD-4-Clause",
"author": "Andres Suarez <zertosh@gmail.com>",
"files": [
"README.md",
"invariant.js",
"browser.js"
],
"repository": {
"type": "git",
"url": "git://github.com/zertosh/invariant.git"
},
"repository": "zertosh/invariant",
"scripts": {
"test": "NODE_ENV=production mocha && NODE_ENV=development mocha"
"test": "NODE_ENV=production tap test/*.js && NODE_ENV=development tap test/*.js"
},
"dependencies": {
"envify": "^3.0.0"
"loose-envify": "^1.0.0"
},
"devDependencies": {
"mocha": "^2.1.0"
"browserify": "^11.0.1",
"tap": "^1.4.0"
},
"engines": {
"node": ">=0.10"
},
"main": "invariant.js",

@@ -32,5 +29,5 @@ "browser": "browser.js",

"transform": [
"envify"
"loose-envify"
]
}
}

@@ -1,21 +0,35 @@

# invariant #
# invariant
A mirror of Facebook's `invariant` (e.g. [React](https://github.com/facebook/react/blob/master/src/vendor/core/invariant.js), [flux](https://github.com/facebook/flux/blob/master/src/invariant.js)).
[![Build Status](https://travis-ci.org/zertosh/invariant.svg?branch=master)](https://travis-ci.org/zertosh/invariant)
### Usage
A mirror of Facebook's `invariant` (e.g. [React](https://github.com/facebook/react/blob/v0.13.3/src/vendor/core/invariant.js), [flux](https://github.com/facebook/flux/blob/2.0.2/src/invariant.js)).
## Install
With [npm](http://npmjs.org) do:
```sh
npm install envify invariant
npm install invariant
```
## `invariant(condition, message)`
```js
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
```
#### Browser
**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.
When used with [`browserify`](https://github.com/substack/node-browserify), it'll use `browser.js` (instead of `invariant.js`) and the [`envify`](https://github.com/hughsk/envify) transform will inline the value of `process.env.NODE_ENV`.
### Browser
#### Node
When used with [browserify](https://github.com/substack/node-browserify), it'll use `browser.js` (instead of `invariant.js`) and the [envify](https://github.com/hughsk/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 `proces.env`. See [Server rendering is slower with npm react #812](https://github.com/facebook/react/issues/812)
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