1 | /**
|
2 | * Copyright (c) 2014-present, Facebook, Inc.
|
3 | *
|
4 | * This source code is licensed under the MIT license found in the
|
5 | * LICENSE file in the root directory of this source tree.
|
6 | *
|
7 | */
|
8 |
|
9 | ;
|
10 |
|
11 | /**
|
12 | * Forked from fbjs/warning:
|
13 | * https://github.com/facebook/fbjs/blob/e66ba20ad5be433eb54423f2b097d829324d9de6/packages/fbjs/src/__forks__/warning.js
|
14 | *
|
15 | * Only change is we use console.warn instead of console.error,
|
16 | * and do nothing when 'console' is not supported.
|
17 | * This really simplifies the code.
|
18 | * ---
|
19 | * Similar to invariant but only logs a warning if the condition is not met.
|
20 | * This can be used to log issues in development environments in critical
|
21 | * paths. Removing the logging code for production environments will keep the
|
22 | * same logic and follow the same code paths.
|
23 | */
|
24 |
|
25 | var lowPriorityWarning = function () {};
|
26 |
|
27 | if (process.env.NODE_ENV !== 'production') {
|
28 | var printWarning = function (format) {
|
29 | for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
30 | args[_key - 1] = arguments[_key];
|
31 | }
|
32 |
|
33 | var argIndex = 0;
|
34 | var message = 'Warning: ' + format.replace(/%s/g, function () {
|
35 | return args[argIndex++];
|
36 | });
|
37 | if (typeof console !== 'undefined') {
|
38 | console.warn(message);
|
39 | }
|
40 | try {
|
41 | // --- Welcome to debugging React ---
|
42 | // This error was thrown as a convenience so that you can use this stack
|
43 | // to find the callsite that caused this warning to fire.
|
44 | throw new Error(message);
|
45 | } catch (x) {}
|
46 | };
|
47 |
|
48 | lowPriorityWarning = function (condition, format) {
|
49 | if (format === undefined) {
|
50 | throw new Error('`warning(condition, format, ...args)` requires a warning ' + 'message argument');
|
51 | }
|
52 | if (!condition) {
|
53 | for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
|
54 | args[_key2 - 2] = arguments[_key2];
|
55 | }
|
56 |
|
57 | printWarning.apply(undefined, [format].concat(args));
|
58 | }
|
59 | };
|
60 | }
|
61 |
|
62 | module.exports = lowPriorityWarning; |
\ | No newline at end of file |