Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
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 7.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. <h1 align=center>
  2. <a href="http://chaijs.com" title="Chai Documentation">
  3. <img alt="ChaiJS" src="http://chaijs.com/img/chai-logo.png"/> type-detect
  4. </a>
  5. </h1>
  6. <br>
  7. <p align=center>
  8. Improved typeof detection for <a href="http://nodejs.org">node</a> and the browser.
  9. </p>
  10. <p align=center>
  11. <a href="./LICENSE">
  12. <img
  13. alt="license:mit"
  14. src="https://img.shields.io/badge/license-mit-green.svg?style=flat-square"
  15. />
  16. </a>
  17. <a href="https://github.com/chaijs/type-detect/releases">
  18. <img
  19. alt="tag:?"
  20. src="https://img.shields.io/github/tag/chaijs/type-detect.svg?style=flat-square"
  21. />
  22. </a>
  23. <a href="https://travis-ci.org/chaijs/type-detect">
  24. <img
  25. alt="build:?"
  26. src="https://img.shields.io/travis/chaijs/type-detect/master.svg?style=flat-square"
  27. />
  28. </a>
  29. <a href="https://coveralls.io/r/chaijs/type-detect">
  30. <img
  31. alt="coverage:?"
  32. src="https://img.shields.io/coveralls/chaijs/type-detect/master.svg?style=flat-square"
  33. />
  34. </a>
  35. <a href="https://www.npmjs.com/packages/type-detect">
  36. <img
  37. alt="npm:?"
  38. src="https://img.shields.io/npm/v/type-detect.svg?style=flat-square"
  39. />
  40. </a>
  41. <a href="https://www.npmjs.com/packages/type-detect">
  42. <img
  43. alt="dependencies:?"
  44. src="https://img.shields.io/npm/dm/type-detect.svg?style=flat-square"
  45. />
  46. </a>
  47. <a href="">
  48. <img
  49. alt="devDependencies:?"
  50. src="https://img.shields.io/david/chaijs/type-detect.svg?style=flat-square"
  51. />
  52. </a>
  53. <br/>
  54. <table>
  55. <tr><th colspan=6>Supported Browsers</th></tr> <tr>
  56. <th align=center><img src="https://camo.githubusercontent.com/ab586f11dfcb49bf5f2c2fa9adadc5e857de122a/687474703a2f2f73766773686172652e636f6d2f692f3278532e737667" alt=""> Chrome</th>
  57. <th align=center><img src="https://camo.githubusercontent.com/98cca3108c18dcfaa62667b42046540c6822cdac/687474703a2f2f73766773686172652e636f6d2f692f3279352e737667" alt=""> Edge</th>
  58. <th align=center><img src="https://camo.githubusercontent.com/acdcb09840a9e1442cbaf1b684f95ab3c3f41cf4/687474703a2f2f73766773686172652e636f6d2f692f3279462e737667" alt=""> Firefox</th>
  59. <th align=center><img src="https://camo.githubusercontent.com/728f8cb0bee9ed58ab85e39266f1152c53e0dffd/687474703a2f2f73766773686172652e636f6d2f692f3278342e737667" alt=""> Safari</th>
  60. <th align=center><img src="https://camo.githubusercontent.com/96a2317034dee0040d0a762e7a30c3c650c45aac/687474703a2f2f73766773686172652e636f6d2f692f3279532e737667" alt=""> IE</th>
  61. </tr><tr>
  62. <td align=center>✅</td>
  63. <td align=center>✅</td>
  64. <td align=center>✅</td>
  65. <td align=center>✅</td>
  66. <td align=center>9, 10, 11</td>
  67. </tr>
  68. </table>
  69. <br>
  70. <a href="https://chai-slack.herokuapp.com/">
  71. <img
  72. alt="Join the Slack chat"
  73. src="https://img.shields.io/badge/slack-join%20chat-E2206F.svg?style=flat-square"
  74. />
  75. </a>
  76. <a href="https://gitter.im/chaijs/chai">
  77. <img
  78. alt="Join the Gitter chat"
  79. src="https://img.shields.io/badge/gitter-join%20chat-D0104D.svg?style=flat-square"
  80. />
  81. </a>
  82. </p>
  83. ## What is Type-Detect?
  84. Type Detect is a module which you can use to detect the type of a given object. It returns a string representation of the object's type, either using [`typeof`](http://www.ecma-international.org/ecma-262/6.0/index.html#sec-typeof-operator) or [`@@toStringTag`](http://www.ecma-international.org/ecma-262/6.0/index.html#sec-symbol.tostringtag). It also normalizes some object names for consistency among browsers.
  85. ## Why?
  86. The `typeof` operator will only specify primitive values; everything else is `"object"` (including `null`, arrays, regexps, etc). Many developers use `Object.prototype.toString()` - which is a fine alternative and returns many more types (null returns `[object Null]`, Arrays as `[object Array]`, regexps as `[object RegExp]` etc).
  87. Sadly, `Object.prototype.toString` is slow, and buggy. By slow - we mean it is slower than `typeof`. By buggy - we mean that some values (like Promises, the global object, iterators, dataviews, a bunch of HTML elements) all report different things in different browsers.
  88. `type-detect` fixes all of the shortcomings with `Object.prototype.toString`. We have extra code to speed up checks of JS and DOM objects, as much as 20-30x faster for some values. `type-detect` also fixes any consistencies with these objects.
  89. ## Installation
  90. ### Node.js
  91. `type-detect` is available on [npm](http://npmjs.org). To install it, type:
  92. $ npm install type-detect
  93. ### Browsers
  94. You can also use it within the browser; install via npm and use the `type-detect.js` file found within the download. For example:
  95. ```html
  96. <script src="./node_modules/type-detect/type-detect.js"></script>
  97. ```
  98. ## Usage
  99. The primary export of `type-detect` is function that can serve as a replacement for `typeof`. The results of this function will be more specific than that of native `typeof`.
  100. ```js
  101. var type = require('type-detect');
  102. ```
  103. #### array
  104. ```js
  105. assert(type([]) === 'Array');
  106. assert(type(new Array()) === 'Array');
  107. ```
  108. #### regexp
  109. ```js
  110. assert(type(/a-z/gi) === 'RegExp');
  111. assert(type(new RegExp('a-z')) === 'RegExp');
  112. ```
  113. #### function
  114. ```js
  115. assert(type(function () {}) === 'function');
  116. ```
  117. #### arguments
  118. ```js
  119. (function () {
  120. assert(type(arguments) === 'Arguments');
  121. })();
  122. ```
  123. #### date
  124. ```js
  125. assert(type(new Date) === 'Date');
  126. ```
  127. #### number
  128. ```js
  129. assert(type(1) === 'number');
  130. assert(type(1.234) === 'number');
  131. assert(type(-1) === 'number');
  132. assert(type(-1.234) === 'number');
  133. assert(type(Infinity) === 'number');
  134. assert(type(NaN) === 'number');
  135. assert(type(new Number(1)) === 'Number'); // note - the object version has a capital N
  136. ```
  137. #### string
  138. ```js
  139. assert(type('hello world') === 'string');
  140. assert(type(new String('hello')) === 'String'); // note - the object version has a capital S
  141. ```
  142. #### null
  143. ```js
  144. assert(type(null) === 'null');
  145. assert(type(undefined) !== 'null');
  146. ```
  147. #### undefined
  148. ```js
  149. assert(type(undefined) === 'undefined');
  150. assert(type(null) !== 'undefined');
  151. ```
  152. #### object
  153. ```js
  154. var Noop = function () {};
  155. assert(type({}) === 'Object');
  156. assert(type(Noop) !== 'Object');
  157. assert(type(new Noop) === 'Object');
  158. assert(type(new Object) === 'Object');
  159. ```
  160. #### ECMA6 Types
  161. All new ECMAScript 2015 objects are also supported, such as Promises and Symbols:
  162. ```js
  163. assert(type(new Map() === 'Map');
  164. assert(type(new WeakMap()) === 'WeakMap');
  165. assert(type(new Set()) === 'Set');
  166. assert(type(new WeakSet()) === 'WeakSet');
  167. assert(type(Symbol()) === 'symbol');
  168. assert(type(new Promise(callback) === 'Promise');
  169. assert(type(new Int8Array()) === 'Int8Array');
  170. assert(type(new Uint8Array()) === 'Uint8Array');
  171. assert(type(new UInt8ClampedArray()) === 'Uint8ClampedArray');
  172. assert(type(new Int16Array()) === 'Int16Array');
  173. assert(type(new Uint16Array()) === 'Uint16Array');
  174. assert(type(new Int32Array()) === 'Int32Array');
  175. assert(type(new UInt32Array()) === 'Uint32Array');
  176. assert(type(new Float32Array()) === 'Float32Array');
  177. assert(type(new Float64Array()) === 'Float64Array');
  178. assert(type(new ArrayBuffer()) === 'ArrayBuffer');
  179. assert(type(new DataView(arrayBuffer)) === 'DataView');
  180. ```
  181. Also, if you use `Symbol.toStringTag` to change an Objects return value of the `toString()` Method, `type()` will return this value, e.g:
  182. ```js
  183. var myObject = {};
  184. myObject[Symbol.toStringTag] = 'myCustomType';
  185. assert(type(myObject) === 'myCustomType');
  186. ```