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

exports

property
module.exports

    Description

    Expose debug() as the module.

    Source

    module.exports = debug;

    names

    declaration
    names

      Description

      Enabled debuggers.

      Source

      var names = []
        , skips = [];
      
      (process.env.DEBUG || '')
        .split(/[\s,]+/)
        .forEach(function(name){
          name = name.replace('*', '.*?');
          if (name[0] === '-') {
            skips.push(new RegExp('^' + name.substr(1) + '$'));
          } else {
            names.push(new RegExp('^' + name + '$'));
          }
        });

      prevColor

      declaration
      prevColor

        Description

        Previously assigned color.

        Source

        var prevColor = 0;

        isatty

        declaration
        isatty

          Description

          Is stdout a TTY? Colored output is disabled when true.

          Source

          var isatty = tty.isatty(2);

          debug

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

          Description

          Create a debugger with the given name.

          Source

          function debug(name) {
            function disabled(){}
            disabled.enabled = false;
          
            var match = skips.some(function(re){
              return re.test(name);
            });
          
            if (match) return disabled;
          
            match = names.some(function(re){
              return re.test(name);
            });
          
            if (!match) return disabled;
            var c = color();
          
            function colored(fmt) {
              var curr = new Date;
              var ms = curr - (prev[name] || curr);
              prev[name] = curr;
          
              fmt = '  \u001b[9' + c + 'm' + name + ' '
                + '\u001b[3' + c + 'm\u001b[90m'
                + fmt + '\u001b[3' + c + 'm'
                + ' +' + humanize(ms) + '\u001b[0m';
          
              console.error.apply(this, arguments);
            }
          
            function plain(fmt) {
              fmt = new Date().toUTCString()
                + ' ' + name + ' ' + fmt;
              console.error.apply(this, arguments);
            }
          
            colored.enabled = plain.enabled = true;
          
            return isatty || process.env.DEBUG_COLORS
              ? colored
              : plain;
          }