dox-foundation-demo node_modules/express/node_modules/debug/debug.js

exports

property
module.exports

    Description

    Expose debug() as the module.

    Source

    module.exports = debug;

    debug

    function
    debug()
    • @param: {String}name
    • @return: {Type}

    Description

    Create a debugger with the given name.

    Source

    function debug(name) {
      if (!debug.enabled(name)) return function(){};
    
      return function(fmt){
        var curr = new Date;
        var ms = curr - (debug[name] || curr);
        debug[name] = curr;
    
        fmt = name
          + ' '
          + fmt
          + ' +' + debug.humanize(ms);
    
        // This hackery is required for IE8
        // where `console.log` doesn't have 'apply'
        window.console
          && console.log
          && Function.prototype.apply.call(console.log, console, arguments);
      }
    }

    names

    property
    debug.names

      Description

      The currently active debug mode names.

      Source

      debug.names = [];
      debug.skips = [];

      enable

      method
      debug.enable()
      • @param: {String}name

      Description

      Enables a debug mode by name. This can include modes
      separated by a colon and wildcards.

      Source

      debug.enable = function(name) {
        try {
          localStorage.debug = name;
        } catch(e){}
      
        var split = (name || '').split(/[\s,]+/)
          , len = split.length;
      
        for (var i = 0; i < len; i++) {
          name = split[i].replace('*', '.*?');
          if (name[0] === '-') {
            debug.skips.push(new RegExp('^' + name.substr(1) + '$'));
          }
          else {
            debug.names.push(new RegExp('^' + name + '$'));
          }
        }
      };

      disable

      method
      debug.disable()

        Description

        Disable debug output.

        Source

        debug.disable = function(){
          debug.enable('');
        };

        enabled

        method
        debug.enabled()
        • @param: {String}name
        • @return: {Boolean}

        Description

        Returns true if the given mode name is enabled, false otherwise.

        Source

        debug.enabled = function(name) {
          for (var i = 0, len = debug.skips.length; i < len; i++) {
            if (debug.skips[i].test(name)) {
              return false;
            }
          }
          for (var i = 0, len = debug.names.length; i < len; i++) {
            if (debug.names[i].test(name)) {
              return true;
            }
          }
          return false;
        };
        
        // persist
        
        if (window.localStorage) debug.enable(localStorage.debug);