Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
81158 views
1
/**
2
* Copyright 2014, Facebook, Inc.
3
* All rights reserved.
4
*
5
* This source code is licensed under the BSD-style license found in the
6
* LICENSE file in the root directory of this source tree. An additional grant
7
* of patent rights can be found in the PATENTS file in the same directory.
8
*
9
* @providesModule warning
10
*/
11
12
"use strict";
13
14
var emptyFunction = require('emptyFunction');
15
16
/**
17
* Similar to invariant but only logs a warning if the condition is not met.
18
* This can be used to log issues in development environments in critical
19
* paths. Removing the logging code for production environments will keep the
20
* same logic and follow the same code paths.
21
*/
22
23
var warning = emptyFunction;
24
25
if (__DEV__) {
26
warning = function(condition, format, ...args) {
27
if (format === undefined) {
28
throw new Error(
29
'`warning(condition, format, ...args)` requires a warning ' +
30
'message argument'
31
);
32
}
33
34
if (!condition) {
35
var argIndex = 0;
36
console.warn('Warning: ' + format.replace(/%s/g, () => args[argIndex++]));
37
}
38
};
39
}
40
41
module.exports = warning;
42
43