diff options
| author | Teddy Wing | 2014-10-30 20:27:55 -0400 | 
|---|---|---|
| committer | Teddy Wing | 2014-10-30 20:27:55 -0400 | 
| commit | fb4b26ac3aa96432fabeaa5b180690a7f5e3c981 (patch) | |
| tree | f3d9c7d231569417f72aab4e12b26d76e0cfed68 /node_modules/debug/node.js | |
| parent | 65600960507d714053d6c7ba99b8e3ced1d6761f (diff) | |
| download | sipping-point-fb4b26ac3aa96432fabeaa5b180690a7f5e3c981.tar.bz2 | |
Add node_modules/
Diffstat (limited to 'node_modules/debug/node.js')
| -rw-r--r-- | node_modules/debug/node.js | 129 | 
1 files changed, 129 insertions, 0 deletions
| diff --git a/node_modules/debug/node.js b/node_modules/debug/node.js new file mode 100644 index 0000000..db86f64 --- /dev/null +++ b/node_modules/debug/node.js @@ -0,0 +1,129 @@ + +/** + * Module dependencies. + */ + +var tty = require('tty'); +var util = require('util'); + +/** + * This is the Node.js implementation of `debug()`. + * + * Expose `debug()` as the module. + */ + +exports = module.exports = require('./debug'); +exports.log = log; +exports.formatArgs = formatArgs; +exports.save = save; +exports.load = load; +exports.useColors = useColors; + +/** + * Colors. + */ + +exports.colors = [6, 2, 3, 4, 5, 1]; + +/** + * Is stdout a TTY? Colored output is enabled when `true`. + */ + +function useColors() { +  var debugColors = (process.env.DEBUG_COLORS || '').trim().toLowerCase(); +  if (0 === debugColors.length) { +    return tty.isatty(1); +  } else { +    return '0' !== debugColors +        && 'no' !== debugColors +        && 'false' !== debugColors +        && 'disabled' !== debugColors; +  } +} + +/** + * Map %o to `util.inspect()`, since Node doesn't do that out of the box. + */ + +var inspect = (4 === util.inspect.length ? +  // node <= 0.8.x +  function (v, colors) { +    return util.inspect(v, void 0, void 0, colors); +  } : +  // node > 0.8.x +  function (v, colors) { +    return util.inspect(v, { colors: colors }); +  } +); + +exports.formatters.o = function(v) { +  return inspect(v, this.useColors) +    .replace(/\s*\n\s*/g, ' '); +}; + +/** + * Adds ANSI color escape codes if enabled. + * + * @api public + */ + +function formatArgs() { +  var args = arguments; +  var useColors = this.useColors; +  var name = this.namespace; + +  if (useColors) { +    var c = this.color; + +    args[0] = '  \u001b[9' + c + 'm' + name + ' ' +      + '\u001b[0m' +      + args[0] + '\u001b[3' + c + 'm' +      + ' +' + exports.humanize(this.diff) + '\u001b[0m'; +  } else { +    args[0] = new Date().toUTCString() +      + ' ' + name + ' ' + args[0]; +  } +  return args; +} + +/** + * Invokes `console.error()` with the specified arguments. + */ + +function log() { +  return console.error.apply(console, arguments); +} + +/** + * Save `namespaces`. + * + * @param {String} namespaces + * @api private + */ + +function save(namespaces) { +  if (null == namespaces) { +    // If you set a process.env field to null or undefined, it gets cast to the +    // string 'null' or 'undefined'. Just delete instead. +    delete process.env.DEBUG; +  } else { +    process.env.DEBUG = namespaces; +  } +} + +/** + * Load `namespaces`. + * + * @return {String} returns the previously persisted debug modes + * @api private + */ + +function load() { +  return process.env.DEBUG; +} + +/** + * Enable namespaces listed in `process.env.DEBUG` initially. + */ + +exports.enable(load()); | 
