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