/warning/browser.js

From disqus.com, 1 Year ago, written in JavaScript, viewed 3 times. This paste is a reply to /http-status-codes/index.js from disqus.com - view diff
URL https://pastebin.freepbx.org/view/5ba1dfee Embed
Download Paste or View Raw
  1. /**
  2.  * Copyright 2014-2015, 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.  
  10. 'use strict';
  11.  
  12. /**
  13.  * Similar to invariant but only logs a warning if the condition is not met.
  14.  * This can be used to log issues in development environments in critical
  15.  * paths. Removing the logging code for production environments will keep the
  16.  * same logic and follow the same code paths.
  17.  */
  18.  
  19. var warning = function() {};
  20.  
  21. if (process.env.NODE_ENV !== 'production') {
  22.   warning = function(condition, format, args) {
  23.     var len = arguments.length;
  24.     args = new Array(len > 2 ? len - 2 : 0);
  25.     for (var key = 2; key < len; key++) {
  26.       args[key - 2] = arguments[key];
  27.     }
  28.     if (format === undefined) {
  29.       throw new Error(
  30.         '`warning(condition, format, ...args)` requires a warning ' +
  31.         'message argument'
  32.       );
  33.     }
  34.  
  35.     if (format.length < 10 || (/^[s\W]*$/).test(format)) {
  36.       throw new Error(
  37.         'The warning format should be able to uniquely identify this ' +
  38.         'warning. Please, use a more descriptive format than: ' + format
  39.       );
  40.     }
  41.  
  42.     if (!condition) {
  43.       var argIndex = 0;
  44.       var message = 'Warning: ' +
  45.         format.replace(/%s/g, function() {
  46.           return args[argIndex++];
  47.         });
  48.       if (typeof console !== 'undefined') {
  49.         console.error(message);
  50.       }
  51.       try {
  52.         // This error was thrown as a convenience so that you can use this stack
  53.         // to find the callsite that caused this warning to fire.
  54.         throw new Error(message);
  55.       } catch(x) {}
  56.     }
  57.   };
  58. }
  59.  
  60. module.exports = warning;
  61.  
  62.  
  63.  
  64. //////////////////
  65. // WEBPACK FOOTER
  66. // ../~/history/~/warning/browser.js
  67. // module id = 58
  68. // module chunks = 0

Replies to /warning/browser.js rss

Title Name Language When
loadCSS.js disqus.com javascript 1 Year ago.

Reply to "/warning/browser.js"

Here you can reply to the paste above