This repository has been archived on 2018-10-12. You can view files and clone it, but cannot push or open issues or pull requests.
node-task/node_modules/express/node_modules/etag
Timothy Warren 21e43fa553 Add csrf module 2014-09-24 17:56:53 -04:00
..
node_modules/crc Add csrf module 2014-09-24 17:56:53 -04:00
HISTORY.md First commit 2014-09-18 15:35:58 -04:00
LICENSE First commit 2014-09-18 15:35:58 -04:00
README.md First commit 2014-09-18 15:35:58 -04:00
index.js First commit 2014-09-18 15:35:58 -04:00
package.json Add csrf module 2014-09-24 17:56:53 -04:00

README.md

etag

NPM Version NPM Downloads Node.js Version Build Status Test Coverage

Create simple ETags

Installation

$ npm install etag

API

var etag = require('etag')

etag(entity, [options])

Generate a strong ETag for the given entity. This should be the complete body of the entity. Strings, Buffers, and fs.Stats are accepted. By default, a strong ETag is generated except for fs.Stats, which will generate a weak ETag (this can be overwritten by options.weak).

res.setHeader('ETag', etag(body))

Options

etag accepts these properties in the options object.

weak

Specifies if a "strong" or a "weak" ETag will be generated. The ETag can only really be a strong as the given input.

Testing

$ npm test

Benchmark

$ npm run-script bench

> etag@1.2.0 bench nodejs-etag
> node benchmark/index.js

> node benchmark/body0-100b.js

  100B body

  1 test completed.
  2 tests completed.
  3 tests completed.
  4 tests completed.

  buffer - strong x   518,895 ops/sec ±1.71% (185 runs sampled)
* buffer - weak   x 1,917,975 ops/sec ±0.34% (195 runs sampled)
  string - strong x   245,251 ops/sec ±0.90% (190 runs sampled)
  string - weak   x   442,232 ops/sec ±0.21% (196 runs sampled)

> node benchmark/body1-1kb.js

  1KB body

  1 test completed.
  2 tests completed.
  3 tests completed.
  4 tests completed.

  buffer - strong x 309,748 ops/sec ±0.99% (191 runs sampled)
* buffer - weak   x 352,402 ops/sec ±0.20% (198 runs sampled)
  string - strong x 159,058 ops/sec ±1.83% (191 runs sampled)
  string - weak   x 184,052 ops/sec ±1.30% (189 runs sampled)

> node benchmark/body2-5kb.js

  5KB body

  1 test completed.
  2 tests completed.
  3 tests completed.
  4 tests completed.

* buffer - strong x 110,157 ops/sec ±0.60% (194 runs sampled)
* buffer - weak   x 111,333 ops/sec ±0.67% (194 runs sampled)
  string - strong x  62,091 ops/sec ±3.92% (186 runs sampled)
  string - weak   x  60,681 ops/sec ±3.98% (186 runs sampled)

> node benchmark/body3-10kb.js

  10KB body

  1 test completed.
  2 tests completed.
  3 tests completed.
  4 tests completed.

* buffer - strong x 61,843 ops/sec ±0.44% (197 runs sampled)
* buffer - weak   x 61,687 ops/sec ±0.52% (197 runs sampled)
  string - strong x 41,377 ops/sec ±3.33% (189 runs sampled)
  string - weak   x 41,368 ops/sec ±3.29% (190 runs sampled)

> node benchmark/body4-100kb.js

  100KB body

  1 test completed.
  2 tests completed.
  3 tests completed.
  4 tests completed.

* buffer - strong x 6,874 ops/sec ±0.17% (198 runs sampled)
* buffer - weak   x 6,880 ops/sec ±0.15% (198 runs sampled)
  string - strong x 5,382 ops/sec ±2.17% (192 runs sampled)
  string - weak   x 5,361 ops/sec ±2.23% (192 runs sampled)

License

MIT