Ohm-Management - Projektarbeit B-ME
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 4.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. # etag
  2. [![NPM Version][npm-image]][npm-url]
  3. [![NPM Downloads][downloads-image]][downloads-url]
  4. [![Node.js Version][node-version-image]][node-version-url]
  5. [![Build Status][travis-image]][travis-url]
  6. [![Test Coverage][coveralls-image]][coveralls-url]
  7. Create simple HTTP ETags
  8. This module generates HTTP ETags (as defined in RFC 7232) for use in
  9. HTTP responses.
  10. ## Installation
  11. This is a [Node.js](https://nodejs.org/en/) module available through the
  12. [npm registry](https://www.npmjs.com/). Installation is done using the
  13. [`npm install` command](https://docs.npmjs.com/getting-started/installing-npm-packages-locally):
  14. ```sh
  15. $ npm install etag
  16. ```
  17. ## API
  18. <!-- eslint-disable no-unused-vars -->
  19. ```js
  20. var etag = require('etag')
  21. ```
  22. ### etag(entity, [options])
  23. Generate a strong ETag for the given entity. This should be the complete
  24. body of the entity. Strings, `Buffer`s, and `fs.Stats` are accepted. By
  25. default, a strong ETag is generated except for `fs.Stats`, which will
  26. generate a weak ETag (this can be overwritten by `options.weak`).
  27. <!-- eslint-disable no-undef -->
  28. ```js
  29. res.setHeader('ETag', etag(body))
  30. ```
  31. #### Options
  32. `etag` accepts these properties in the options object.
  33. ##### weak
  34. Specifies if the generated ETag will include the weak validator mark (that
  35. is, the leading `W/`). The actual entity tag is the same. The default value
  36. is `false`, unless the `entity` is `fs.Stats`, in which case it is `true`.
  37. ## Testing
  38. ```sh
  39. $ npm test
  40. ```
  41. ## Benchmark
  42. ```bash
  43. $ npm run-script bench
  44. > etag@1.8.1 bench nodejs-etag
  45. > node benchmark/index.js
  46. http_parser@2.7.0
  47. node@6.11.1
  48. v8@5.1.281.103
  49. uv@1.11.0
  50. zlib@1.2.11
  51. ares@1.10.1-DEV
  52. icu@58.2
  53. modules@48
  54. openssl@1.0.2k
  55. > node benchmark/body0-100b.js
  56. 100B body
  57. 4 tests completed.
  58. buffer - strong x 258,647 ops/sec ±1.07% (180 runs sampled)
  59. buffer - weak x 263,812 ops/sec ±0.61% (184 runs sampled)
  60. string - strong x 259,955 ops/sec ±1.19% (185 runs sampled)
  61. string - weak x 264,356 ops/sec ±1.09% (184 runs sampled)
  62. > node benchmark/body1-1kb.js
  63. 1KB body
  64. 4 tests completed.
  65. buffer - strong x 189,018 ops/sec ±1.12% (182 runs sampled)
  66. buffer - weak x 190,586 ops/sec ±0.81% (186 runs sampled)
  67. string - strong x 144,272 ops/sec ±0.96% (188 runs sampled)
  68. string - weak x 145,380 ops/sec ±1.43% (187 runs sampled)
  69. > node benchmark/body2-5kb.js
  70. 5KB body
  71. 4 tests completed.
  72. buffer - strong x 92,435 ops/sec ±0.42% (188 runs sampled)
  73. buffer - weak x 92,373 ops/sec ±0.58% (189 runs sampled)
  74. string - strong x 48,850 ops/sec ±0.56% (186 runs sampled)
  75. string - weak x 49,380 ops/sec ±0.56% (190 runs sampled)
  76. > node benchmark/body3-10kb.js
  77. 10KB body
  78. 4 tests completed.
  79. buffer - strong x 55,989 ops/sec ±0.93% (188 runs sampled)
  80. buffer - weak x 56,148 ops/sec ±0.55% (190 runs sampled)
  81. string - strong x 27,345 ops/sec ±0.43% (188 runs sampled)
  82. string - weak x 27,496 ops/sec ±0.45% (190 runs sampled)
  83. > node benchmark/body4-100kb.js
  84. 100KB body
  85. 4 tests completed.
  86. buffer - strong x 7,083 ops/sec ±0.22% (190 runs sampled)
  87. buffer - weak x 7,115 ops/sec ±0.26% (191 runs sampled)
  88. string - strong x 3,068 ops/sec ±0.34% (190 runs sampled)
  89. string - weak x 3,096 ops/sec ±0.35% (190 runs sampled)
  90. > node benchmark/stats.js
  91. stat
  92. 4 tests completed.
  93. real - strong x 871,642 ops/sec ±0.34% (189 runs sampled)
  94. real - weak x 867,613 ops/sec ±0.39% (190 runs sampled)
  95. fake - strong x 401,051 ops/sec ±0.40% (189 runs sampled)
  96. fake - weak x 400,100 ops/sec ±0.47% (188 runs sampled)
  97. ```
  98. ## License
  99. [MIT](LICENSE)
  100. [npm-image]: https://img.shields.io/npm/v/etag.svg
  101. [npm-url]: https://npmjs.org/package/etag
  102. [node-version-image]: https://img.shields.io/node/v/etag.svg
  103. [node-version-url]: https://nodejs.org/en/download/
  104. [travis-image]: https://img.shields.io/travis/jshttp/etag/master.svg
  105. [travis-url]: https://travis-ci.org/jshttp/etag
  106. [coveralls-image]: https://img.shields.io/coveralls/jshttp/etag/master.svg
  107. [coveralls-url]: https://coveralls.io/r/jshttp/etag?branch=master
  108. [downloads-image]: https://img.shields.io/npm/dm/etag.svg
  109. [downloads-url]: https://npmjs.org/package/etag