2.2.4 • Published 6 years ago

invariant v2.2.4

Weekly downloads
11,382,438
License
MIT
Repository
github
Last release
6 years ago

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

babel-traverse@reach/routerreact-sizemereact-helmet-asyncrelay-runtimebabel-preset-env@wouterds/react-native-tvos42-expo@modern-js/runtime@nocturne92/redux-falcoradspilot-uiarchetype-librarycarbon-react@contiago/toolbar@gooddata/react-components@gooddata/goodstrap@codecademy/styleguide@codecademy/gamut@helpscout/hsds-react@ledgerhq/live-cli@ledgerhq/live-commonpwc-expoeasy-select-rn@haravan/app-authtest-g-pcsola-react-nativetim-dva-corereact-native-bluetooth2killi8n-react-native-fast-image@invoice-simple/react-intl@likethemammal/react-primitives@likethemammal/react-primitives_react-native-web_latest@sinakhx/react-big-calendarreact-native-for-sanbotparadicms-base@tetherless-world/twxplore-base-libstrapi-plugin-upload-filepond@miot-plugin/react-navigation-redux-helperscarbon-addons-boomerang-react@epranka/test-schema@that1matt/react-css-themrjsx-stylexcaoliao-helper-plugincaoliao-plugin-content-managercaoliao-plugin-content-type-buildercaoliao-plugin-documentationcaoliao-plugin-settings-managercaoliao-plugin-uploadcaoliao-plugin-users-permissionsflowbuilder-test@fadi-saadeldin/react-big-calenderrn-send-smsrand-react-helmet-asyncr15-happy-router@amra-finance/ding@icanpm/api-master@runjuuu/react-native-webviewbutton-animations-react@darcusfenix/react-redux@darcusfenix/redux-form@mallpay/routerreact-tools-cliweb-deployredux-reqs@arisageha/react-lazyload@arisageha/react-lazyload-fixinfoniqa-client-corereact-awesome-tab@danielballardp/infoniqa-client-core@cashremit/cr-streamline-icons@sellics/rankingsreact-native-wk-viewreact-native-sketchappevaformrn-device-informationreplot-wordcloud@composer/routerredux-questvaluecoupon@paradicms/basegatsby-theme-lumenreact-redux-combine-components@nick-thompson/react-jucereact-native-template-rfbase@zaydek/document-titlevscode-intl-javascript-plugin-mdsegenie-rn-react-native-communityairscanairscan-examplepock-meta-statebb-chatredux-form-5redux-remakereact-native-esc-pos-sahaabmotivated@ihikmawan/tailwindcss-multi-theme-l2@borisovart/atol-kkt-module@phil8795/pecuniarius-api@drawerapp/react-native-webview@hgc-ab/core
2.2.4

6 years ago

2.2.3

6 years ago

2.2.2

7 years ago

2.2.1

8 years ago

2.2.0

8 years ago

2.1.3

8 years ago

2.1.2

8 years ago

2.1.1

9 years ago

2.1.0

9 years ago

2.0.0

9 years ago

1.0.2

10 years ago

1.0.1

10 years ago

1.0.0

10 years ago