UNPKG

446 BJavaScriptView Raw
1'use strict';
2
3var isProduction = process.env.NODE_ENV === 'production';
4var prefix = 'Invariant failed';
5function invariant(condition, message) {
6 if (condition) {
7 return;
8 }
9 if (isProduction) {
10 throw new Error(prefix);
11 }
12 var provided = typeof message === 'function' ? message() : message;
13 var value = provided ? prefix + ": " + provided : prefix;
14 throw new Error(value);
15}
16
17module.exports = invariant;