UNPKG

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