aboutsummaryrefslogtreecommitdiff
path: root/node_modules/fbjs/lib/warning.js.flow
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/fbjs/lib/warning.js.flow')
-rw-r--r--node_modules/fbjs/lib/warning.js.flow55
1 files changed, 55 insertions, 0 deletions
diff --git a/node_modules/fbjs/lib/warning.js.flow b/node_modules/fbjs/lib/warning.js.flow
new file mode 100644
index 000000000..a42d54bf6
--- /dev/null
+++ b/node_modules/fbjs/lib/warning.js.flow
@@ -0,0 +1,55 @@
+/**
+ * Copyright 2014-2015, Facebook, Inc.
+ * All rights reserved.
+ *
+ * This source code is licensed under the BSD-style license found in the
+ * LICENSE file in the root directory of this source tree. An additional grant
+ * of patent rights can be found in the PATENTS file in the same directory.
+ *
+ * @providesModule warning
+ */
+
+'use strict';
+
+var emptyFunction = require('./emptyFunction');
+
+/**
+ * Similar to invariant but only logs a warning if the condition is not met.
+ * This can be used to log issues in development environments in critical
+ * paths. Removing the logging code for production environments will keep the
+ * same logic and follow the same code paths.
+ */
+
+var warning = emptyFunction;
+
+if (__DEV__) {
+ function printWarning(format, ...args) {
+ var argIndex = 0;
+ var message = 'Warning: ' + format.replace(/%s/g, () => args[argIndex++]);
+ if (typeof console !== 'undefined') {
+ console.error(message);
+ }
+ try {
+ // --- Welcome to debugging React ---
+ // This error was thrown as a convenience so that you can use this stack
+ // to find the callsite that caused this warning to fire.
+ throw new Error(message);
+ } catch (x) {}
+ }
+
+ warning = function (condition, format, ...args) {
+ if (format === undefined) {
+ throw new Error('`warning(condition, format, ...args)` requires a warning ' + 'message argument');
+ }
+
+ if (format.indexOf('Failed Composite propType: ') === 0) {
+ return; // Ignore CompositeComponent proptype check.
+ }
+
+ if (!condition) {
+ printWarning(format, ...args);
+ }
+ };
+}
+
+module.exports = warning; \ No newline at end of file