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.

Readme.md 9.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. # depd
  2. [![NPM Version][npm-version-image]][npm-url]
  3. [![NPM Downloads][npm-downloads-image]][npm-url]
  4. [![Node.js Version][node-image]][node-url]
  5. [![Build Status][travis-image]][travis-url]
  6. [![Coverage Status][coveralls-image]][coveralls-url]
  7. [![Gittip][gittip-image]][gittip-url]
  8. Deprecate all the things
  9. > With great modules comes great responsibility; mark things deprecated!
  10. ## Install
  11. ```sh
  12. $ npm install depd
  13. ```
  14. ## API
  15. ```js
  16. var deprecate = require('depd')('my-module')
  17. ```
  18. This library allows you to display deprecation messages to your users.
  19. This library goes above and beyond with deprecation warnings by
  20. introspecting the call stack (but only the bits that it is interested
  21. in).
  22. Instead of just warning on the first invocation of a deprecated
  23. function and never again, this module will warn on the first invocation
  24. of a deprecated function per unique call site, making it ideal to alert
  25. users of all deprecated uses across the code base, rather than just
  26. whatever happens to execute first.
  27. The deprecation warnings from this module also include the file and line
  28. information for the call into the module that the deprecated function was
  29. in.
  30. ### depd(namespace)
  31. Create a new deprecate function that uses the given namespace name in the
  32. messages and will display the call site prior to the stack entering the
  33. file this function was called from. It is highly suggested you use the
  34. name of your module as the namespace.
  35. ### deprecate(message)
  36. Call this function from deprecated code to display a deprecation message.
  37. This message will appear once per unique caller site. Caller site is the
  38. first call site in the stack in a different file from the caller of this
  39. function.
  40. If the message is omitted, a message is generated for you based on the site
  41. of the `deprecate()` call and will display the name of the function called,
  42. similar to the name displayed in a stack trace.
  43. ### deprecate.function(fn, message)
  44. Call this function to wrap a given function in a deprecation message on any
  45. call to the function. An optional message can be supplied to provide a custom
  46. message.
  47. ### deprecate.property(obj, prop, message)
  48. Call this function to wrap a given property on object in a deprecation message
  49. on any accessing or setting of the property. An optional message can be supplied
  50. to provide a custom message.
  51. The method must be called on the object where the property belongs (not
  52. inherited from the prototype).
  53. If the property is a data descriptor, it will be converted to an accessor
  54. descriptor in order to display the deprecation message.
  55. ### process.on('deprecation', fn)
  56. This module will allow easy capturing of deprecation errors by emitting the
  57. errors as the type "deprecation" on the global `process`. If there are no
  58. listeners for this type, the errors are written to STDERR as normal, but if
  59. there are any listeners, nothing will be written to STDERR and instead only
  60. emitted. From there, you can write the errors in a different format or to a
  61. logging source.
  62. The error represents the deprecation and is emitted only once with the same
  63. rules as writing to STDERR. The error has the following properties:
  64. - `message` - This is the message given by the library
  65. - `name` - This is always `'DeprecationError'`
  66. - `namespace` - This is the namespace the deprecation came from
  67. - `stack` - This is the stack of the call to the deprecated thing
  68. Example `error.stack` output:
  69. ```
  70. DeprecationError: my-cool-module deprecated oldfunction
  71. at Object.<anonymous> ([eval]-wrapper:6:22)
  72. at Module._compile (module.js:456:26)
  73. at evalScript (node.js:532:25)
  74. at startup (node.js:80:7)
  75. at node.js:902:3
  76. ```
  77. ### process.env.NO_DEPRECATION
  78. As a user of modules that are deprecated, the environment variable `NO_DEPRECATION`
  79. is provided as a quick solution to silencing deprecation warnings from being
  80. output. The format of this is similar to that of `DEBUG`:
  81. ```sh
  82. $ NO_DEPRECATION=my-module,othermod node app.js
  83. ```
  84. This will suppress deprecations from being output for "my-module" and "othermod".
  85. The value is a list of comma-separated namespaces. To suppress every warning
  86. across all namespaces, use the value `*` for a namespace.
  87. Providing the argument `--no-deprecation` to the `node` executable will suppress
  88. all deprecations (only available in Node.js 0.8 or higher).
  89. **NOTE** This will not suppress the deperecations given to any "deprecation"
  90. event listeners, just the output to STDERR.
  91. ### process.env.TRACE_DEPRECATION
  92. As a user of modules that are deprecated, the environment variable `TRACE_DEPRECATION`
  93. is provided as a solution to getting more detailed location information in deprecation
  94. warnings by including the entire stack trace. The format of this is the same as
  95. `NO_DEPRECATION`:
  96. ```sh
  97. $ TRACE_DEPRECATION=my-module,othermod node app.js
  98. ```
  99. This will include stack traces for deprecations being output for "my-module" and
  100. "othermod". The value is a list of comma-separated namespaces. To trace every
  101. warning across all namespaces, use the value `*` for a namespace.
  102. Providing the argument `--trace-deprecation` to the `node` executable will trace
  103. all deprecations (only available in Node.js 0.8 or higher).
  104. **NOTE** This will not trace the deperecations silenced by `NO_DEPRECATION`.
  105. ## Display
  106. ![message](files/message.png)
  107. When a user calls a function in your library that you mark deprecated, they
  108. will see the following written to STDERR (in the given colors, similar colors
  109. and layout to the `debug` module):
  110. ```
  111. bright cyan bright yellow
  112. | | reset cyan
  113. | | | |
  114. ▼ ▼ ▼ ▼
  115. my-cool-module deprecated oldfunction [eval]-wrapper:6:22
  116. ▲ ▲ ▲ ▲
  117. | | | |
  118. namespace | | location of mycoolmod.oldfunction() call
  119. | deprecation message
  120. the word "deprecated"
  121. ```
  122. If the user redirects their STDERR to a file or somewhere that does not support
  123. colors, they see (similar layout to the `debug` module):
  124. ```
  125. Sun, 15 Jun 2014 05:21:37 GMT my-cool-module deprecated oldfunction at [eval]-wrapper:6:22
  126. ▲ ▲ ▲ ▲ ▲
  127. | | | | |
  128. timestamp of message namespace | | location of mycoolmod.oldfunction() call
  129. | deprecation message
  130. the word "deprecated"
  131. ```
  132. ## Examples
  133. ### Deprecating all calls to a function
  134. This will display a deprecated message about "oldfunction" being deprecated
  135. from "my-module" on STDERR.
  136. ```js
  137. var deprecate = require('depd')('my-cool-module')
  138. // message automatically derived from function name
  139. // Object.oldfunction
  140. exports.oldfunction = deprecate.function(function oldfunction() {
  141. // all calls to function are deprecated
  142. })
  143. // specific message
  144. exports.oldfunction = deprecate.function(function () {
  145. // all calls to function are deprecated
  146. }, 'oldfunction')
  147. ```
  148. ### Conditionally deprecating a function call
  149. This will display a deprecated message about "weirdfunction" being deprecated
  150. from "my-module" on STDERR when called with less than 2 arguments.
  151. ```js
  152. var deprecate = require('depd')('my-cool-module')
  153. exports.weirdfunction = function () {
  154. if (arguments.length < 2) {
  155. // calls with 0 or 1 args are deprecated
  156. deprecate('weirdfunction args < 2')
  157. }
  158. }
  159. ```
  160. When calling `deprecate` as a function, the warning is counted per call site
  161. within your own module, so you can display different deprecations depending
  162. on different situations and the users will still get all the warnings:
  163. ```js
  164. var deprecate = require('depd')('my-cool-module')
  165. exports.weirdfunction = function () {
  166. if (arguments.length < 2) {
  167. // calls with 0 or 1 args are deprecated
  168. deprecate('weirdfunction args < 2')
  169. } else if (typeof arguments[0] !== 'string') {
  170. // calls with non-string first argument are deprecated
  171. deprecate('weirdfunction non-string first arg')
  172. }
  173. }
  174. ```
  175. ### Deprecating property access
  176. This will display a deprecated message about "oldprop" being deprecated
  177. from "my-module" on STDERR when accessed. A deprecation will be displayed
  178. when setting the value and when getting the value.
  179. ```js
  180. var deprecate = require('depd')('my-cool-module')
  181. exports.oldprop = 'something'
  182. // message automatically derives from property name
  183. deprecate.property(exports, 'oldprop')
  184. // explicit message
  185. deprecate.property(exports, 'oldprop', 'oldprop >= 0.10')
  186. ```
  187. ## License
  188. [MIT](LICENSE)
  189. [npm-version-image]: https://img.shields.io/npm/v/depd.svg?style=flat
  190. [npm-downloads-image]: https://img.shields.io/npm/dm/depd.svg?style=flat
  191. [npm-url]: https://npmjs.org/package/depd
  192. [travis-image]: https://img.shields.io/travis/dougwilson/nodejs-depd.svg?style=flat
  193. [travis-url]: https://travis-ci.org/dougwilson/nodejs-depd
  194. [coveralls-image]: https://img.shields.io/coveralls/dougwilson/nodejs-depd.svg?style=flat
  195. [coveralls-url]: https://coveralls.io/r/dougwilson/nodejs-depd?branch=master
  196. [node-image]: https://img.shields.io/node/v/depd.svg?style=flat
  197. [node-url]: http://nodejs.org/download/
  198. [gittip-image]: https://img.shields.io/gittip/dougwilson.svg?style=flat
  199. [gittip-url]: https://www.gittip.com/dougwilson/