1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 | 'use strict';
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 | var NODE_ENV = process.env.NODE_ENV;
|
22 |
|
23 | var invariant = function(condition, format, a, b, c, d, e, f) {
|
24 | if (NODE_ENV !== 'production') {
|
25 | if (format === undefined) {
|
26 | throw new Error('invariant requires an error message argument');
|
27 | }
|
28 | }
|
29 |
|
30 | if (!condition) {
|
31 | var error;
|
32 | if (format === undefined) {
|
33 | error = new Error(
|
34 | 'Minified exception occurred; use the non-minified dev environment ' +
|
35 | 'for the full error message and additional helpful warnings.'
|
36 | );
|
37 | } else {
|
38 | var args = [a, b, c, d, e, f];
|
39 | var argIndex = 0;
|
40 | error = new Error(
|
41 | format.replace(/%s/g, function() { return args[argIndex++]; })
|
42 | );
|
43 | error.name = 'Invariant Violation';
|
44 | }
|
45 |
|
46 | error.framesToPop = 1;
|
47 | throw error;
|
48 | }
|
49 | };
|
50 |
|
51 | module.exports = invariant;
|