Package Exports
- etag
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (etag) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
etag
Create simple ETags
Installation
$ npm install etagAPI
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 string or fs.Stats will generate a weak ETag while a Buffer
will generate a strong 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 testBenchmark
$ 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 464,089 ops/sec ±1.38% (185 runs sampled)
buffer - weak x 1,154,033 ops/sec ±0.24% (195 runs sampled)
string - strong x 222,036 ops/sec ±0.98% (188 runs sampled)
string - weak x 374,874 ops/sec ±0.52% (193 runs sampled)
> node benchmark/body1-1kb.js
1KB body
1 test completed.
2 tests completed.
3 tests completed.
4 tests completed.
buffer - strong x 293,836 ops/sec ±1.01% (190 runs sampled)
buffer - weak x 300,585 ops/sec ±0.21% (195 runs sampled)
string - strong x 156,011 ops/sec ±2.01% (187 runs sampled)
string - weak x 167,002 ops/sec ±1.28% (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 102,942 ops/sec ±0.76% (193 runs sampled)
buffer - weak x 69,593 ops/sec ±0.39% (193 runs sampled)
string - strong x 58,533 ops/sec ±3.97% (185 runs sampled)
string - weak x 46,991 ops/sec ±3.05% (189 runs sampled)
> node benchmark/body3-10kb.js
10KB body
1 test completed.
2 tests completed.
3 tests completed.
4 tests completed.
buffer - strong x 57,475 ops/sec ±0.61% (193 runs sampled)
buffer - weak x 36,124 ops/sec ±0.21% (194 runs sampled)
string - strong x 38,994 ops/sec ±3.31% (187 runs sampled)
string - weak x 27,801 ops/sec ±2.56% (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,593 ops/sec ±0.21% (197 runs sampled)
buffer - weak x 3,719 ops/sec ±0.18% (195 runs sampled)
string - strong x 5,125 ops/sec ±2.24% (191 runs sampled)
string - weak x 3,181 ops/sec ±1.90% (192 runs sampled)