Ein Projekt das es ermöglicht Beerpong über das Internet von zwei unabhängigen positionen aus zu spielen. Entstehung im Rahmen einer Praktikumsaufgabe im Fach Interaktion.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

node.js 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. /**
  2. * Module dependencies.
  3. */
  4. var tty = require('tty');
  5. var util = require('util');
  6. /**
  7. * This is the Node.js implementation of `debug()`.
  8. *
  9. * Expose `debug()` as the module.
  10. */
  11. exports = module.exports = require('./debug');
  12. exports.log = log;
  13. exports.formatArgs = formatArgs;
  14. exports.save = save;
  15. exports.load = load;
  16. exports.useColors = useColors;
  17. /**
  18. * Colors.
  19. */
  20. exports.colors = [6, 2, 3, 4, 5, 1];
  21. /**
  22. * Is stdout a TTY? Colored output is enabled when `true`.
  23. */
  24. function useColors() {
  25. var debugColors = (process.env.DEBUG_COLORS || '').trim().toLowerCase();
  26. if (0 === debugColors.length) {
  27. return tty.isatty(1);
  28. } else {
  29. return '0' !== debugColors
  30. && 'no' !== debugColors
  31. && 'false' !== debugColors
  32. && 'disabled' !== debugColors;
  33. }
  34. }
  35. /**
  36. * Map %o to `util.inspect()`, since Node doesn't do that out of the box.
  37. */
  38. var inspect = (4 === util.inspect.length ?
  39. // node <= 0.8.x
  40. function (v, colors) {
  41. return util.inspect(v, void 0, void 0, colors);
  42. } :
  43. // node > 0.8.x
  44. function (v, colors) {
  45. return util.inspect(v, { colors: colors });
  46. }
  47. );
  48. exports.formatters.o = function(v) {
  49. return inspect(v, this.useColors)
  50. .replace(/\s*\n\s*/g, ' ');
  51. };
  52. /**
  53. * Adds ANSI color escape codes if enabled.
  54. *
  55. * @api public
  56. */
  57. function formatArgs() {
  58. var args = arguments;
  59. var useColors = this.useColors;
  60. var name = this.namespace;
  61. if (useColors) {
  62. var c = this.color;
  63. args[0] = ' \u001b[9' + c + 'm' + name + ' '
  64. + '\u001b[0m'
  65. + args[0] + '\u001b[3' + c + 'm'
  66. + ' +' + exports.humanize(this.diff) + '\u001b[0m';
  67. } else {
  68. args[0] = new Date().toUTCString()
  69. + ' ' + name + ' ' + args[0];
  70. }
  71. return args;
  72. }
  73. /**
  74. * Invokes `console.error()` with the specified arguments.
  75. */
  76. function log() {
  77. return console.error.apply(console, arguments);
  78. }
  79. /**
  80. * Save `namespaces`.
  81. *
  82. * @param {String} namespaces
  83. * @api private
  84. */
  85. function save(namespaces) {
  86. if (null == namespaces) {
  87. // If you set a process.env field to null or undefined, it gets cast to the
  88. // string 'null' or 'undefined'. Just delete instead.
  89. delete process.env.DEBUG;
  90. } else {
  91. process.env.DEBUG = namespaces;
  92. }
  93. }
  94. /**
  95. * Load `namespaces`.
  96. *
  97. * @return {String} returns the previously persisted debug modes
  98. * @api private
  99. */
  100. function load() {
  101. return process.env.DEBUG;
  102. }
  103. /**
  104. * Enable namespaces listed in `process.env.DEBUG` initially.
  105. */
  106. exports.enable(load());