Socket
Socket
Sign inDemoInstall

etag

Package Overview
Dependencies
0
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.7.0 to 1.8.0

7

HISTORY.md

@@ -0,1 +1,8 @@

1.8.0 / 2017-02-18
==================
* Use SHA1 instead of MD5 for ETag hashing
- Improves performance for larger entities
- Works with FIPS 140-2 OpenSSL configuration
1.7.0 / 2015-06-08

@@ -2,0 +9,0 @@ ==================

24

index.js
/*!
* etag
* Copyright(c) 2014-2015 Douglas Christopher Wilson
* Copyright(c) 2014-2016 Douglas Christopher Wilson
* MIT Licensed

@@ -40,6 +40,6 @@ */

function entitytag(entity) {
function entitytag (entity) {
if (entity.length === 0) {
// fast-path empty
return '"0-1B2M2Y8AsgTpgAmY7PhCfg"'
return '"0-2jmj7l5rSw0yVb/vlWAYkK/YBwk"'
}

@@ -49,3 +49,3 @@

var hash = crypto
.createHash('md5')
.createHash('sha1')
.update(entity, 'utf8')

@@ -73,3 +73,3 @@ .digest('base64')

function etag(entity, options) {
function etag (entity, options) {
if (entity == null) {

@@ -108,3 +108,3 @@ throw new TypeError('argument entity is required')

function isstats(obj) {
function isstats (obj) {
// genuine fs.Stats

@@ -116,7 +116,7 @@ if (typeof Stats === 'function' && obj instanceof Stats) {

// quack quack
return obj && typeof obj === 'object'
&& 'ctime' in obj && toString.call(obj.ctime) === '[object Date]'
&& 'mtime' in obj && toString.call(obj.mtime) === '[object Date]'
&& 'ino' in obj && typeof obj.ino === 'number'
&& 'size' in obj && typeof obj.size === 'number'
return obj && typeof obj === 'object' &&
'ctime' in obj && toString.call(obj.ctime) === '[object Date]' &&
'mtime' in obj && toString.call(obj.mtime) === '[object Date]' &&
'ino' in obj && typeof obj.ino === 'number' &&
'size' in obj && typeof obj.size === 'number'
}

@@ -132,3 +132,3 @@

function stattag(stat) {
function stattag (stat) {
var mtime = stat.mtime.getTime().toString(16)

@@ -135,0 +135,0 @@ var size = stat.size.toString(16)

{
"name": "etag",
"description": "Create simple ETags",
"version": "1.7.0",
"description": "Create simple HTTP ETags",
"version": "1.8.0",
"contributors": [

@@ -17,7 +17,12 @@ "Douglas Christopher Wilson <doug@somethingdoug.com>",

"devDependencies": {
"benchmark": "1.0.0",
"beautify-benchmark": "0.2.4",
"istanbul": "0.3.14",
"mocha": "~1.21.4",
"seedrandom": "2.3.11"
"benchmark": "2.1.3",
"eslint": "3.15.0",
"eslint-config-standard": "6.2.1",
"eslint-plugin-markdown": "1.0.0-beta.3",
"eslint-plugin-promise": "3.4.2",
"eslint-plugin-standard": "2.0.1",
"istanbul": "0.4.5",
"mocha": "1.21.5",
"seedrandom": "2.4.2"
},

@@ -35,2 +40,3 @@ "files": [

"bench": "node benchmark/index.js",
"lint": "eslint --plugin markdown --ext js,md .",
"test": "mocha --reporter spec --bail --check-leaks test/",

@@ -37,0 +43,0 @@ "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/",

@@ -9,6 +9,13 @@ # etag

Create simple ETags
Create simple HTTP ETags
This module generates HTTP ETags (as defined in RFC 7232) for use in
HTTP responses.
## Installation
This is a [Node.js](https://nodejs.org/en/) module available through the
[npm registry](https://www.npmjs.com/). Installation is done using the
[`npm install` command](https://docs.npmjs.com/getting-started/installing-npm-packages-locally):
```sh

@@ -20,2 +27,4 @@ $ npm install etag

<!-- eslint-disable no-unused-vars -->
```js

@@ -32,2 +41,4 @@ var etag = require('etag')

<!-- eslint-disable no-undef -->
```js

@@ -58,13 +69,14 @@ res.setHeader('ETag', etag(body))

> etag@1.6.0 bench nodejs-etag
> etag@1.8.0 bench nodejs-etag
> node benchmark/index.js
http_parser@1.0
node@0.10.33
v8@3.14.5.9
ares@1.9.0-DEV
uv@0.10.29
zlib@1.2.3
modules@11
openssl@1.0.1j
http_parser@2.7.0
node@6.9.1
v8@5.1.281.84
uv@1.9.1
zlib@1.2.8
ares@1.10.1-DEV
icu@57.1
modules@48
openssl@1.0.2j

@@ -75,11 +87,8 @@ > node benchmark/body0-100b.js

1 test completed.
2 tests completed.
3 tests completed.
4 tests completed.
* buffer - strong x 289,198 ops/sec ±1.09% (190 runs sampled)
* buffer - weak x 287,838 ops/sec ±0.91% (189 runs sampled)
* string - strong x 284,586 ops/sec ±1.05% (192 runs sampled)
* string - weak x 287,439 ops/sec ±0.82% (192 runs sampled)
* buffer - strong x 498,600 ops/sec ±0.82% (191 runs sampled)
* buffer - weak x 496,249 ops/sec ±0.59% (179 runs sampled)
string - strong x 466,298 ops/sec ±0.88% (186 runs sampled)
string - weak x 464,298 ops/sec ±0.84% (184 runs sampled)

@@ -90,11 +99,8 @@ > node benchmark/body1-1kb.js

1 test completed.
2 tests completed.
3 tests completed.
4 tests completed.
* buffer - strong x 212,423 ops/sec ±0.75% (193 runs sampled)
* buffer - weak x 211,871 ops/sec ±0.74% (194 runs sampled)
string - strong x 205,291 ops/sec ±0.86% (194 runs sampled)
string - weak x 208,463 ops/sec ±0.79% (192 runs sampled)
* buffer - strong x 346,535 ops/sec ±0.32% (189 runs sampled)
* buffer - weak x 344,958 ops/sec ±0.52% (185 runs sampled)
string - strong x 259,672 ops/sec ±0.82% (191 runs sampled)
string - weak x 260,931 ops/sec ±0.76% (190 runs sampled)

@@ -105,11 +111,8 @@ > node benchmark/body2-5kb.js

1 test completed.
2 tests completed.
3 tests completed.
4 tests completed.
* buffer - strong x 92,901 ops/sec ±0.58% (195 runs sampled)
* buffer - weak x 93,045 ops/sec ±0.65% (192 runs sampled)
string - strong x 89,621 ops/sec ±0.68% (194 runs sampled)
string - weak x 90,070 ops/sec ±0.70% (196 runs sampled)
* buffer - strong x 136,510 ops/sec ±0.62% (189 runs sampled)
* buffer - weak x 136,604 ops/sec ±0.51% (191 runs sampled)
string - strong x 80,903 ops/sec ±0.84% (192 runs sampled)
string - weak x 82,785 ops/sec ±0.50% (193 runs sampled)

@@ -120,11 +123,8 @@ > node benchmark/body3-10kb.js

1 test completed.
2 tests completed.
3 tests completed.
4 tests completed.
* buffer - strong x 54,220 ops/sec ±0.85% (192 runs sampled)
* buffer - weak x 54,069 ops/sec ±0.83% (191 runs sampled)
string - strong x 53,078 ops/sec ±0.53% (194 runs sampled)
string - weak x 53,849 ops/sec ±0.47% (197 runs sampled)
* buffer - strong x 78,650 ops/sec ±0.31% (193 runs sampled)
* buffer - weak x 78,685 ops/sec ±0.41% (193 runs sampled)
string - strong x 43,999 ops/sec ±0.43% (193 runs sampled)
string - weak x 44,081 ops/sec ±0.45% (192 runs sampled)

@@ -135,25 +135,19 @@ > node benchmark/body4-100kb.js

1 test completed.
2 tests completed.
3 tests completed.
4 tests completed.
* buffer - strong x 6,673 ops/sec ±0.15% (197 runs sampled)
* buffer - weak x 6,716 ops/sec ±0.12% (198 runs sampled)
string - strong x 6,357 ops/sec ±0.14% (197 runs sampled)
string - weak x 6,344 ops/sec ±0.21% (197 runs sampled)
buffer - strong x 8,860 ops/sec ±0.66% (191 runs sampled)
* buffer - weak x 9,030 ops/sec ±0.26% (193 runs sampled)
string - strong x 4,838 ops/sec ±0.16% (194 runs sampled)
string - weak x 4,800 ops/sec ±0.52% (192 runs sampled)
> node benchmark/stats.js
stats
stat
1 test completed.
2 tests completed.
3 tests completed.
4 tests completed.
* real - strong x 1,671,989 ops/sec ±0.13% (197 runs sampled)
* real - weak x 1,681,297 ops/sec ±0.12% (198 runs sampled)
fake - strong x 927,063 ops/sec ±0.14% (198 runs sampled)
fake - weak x 914,461 ops/sec ±0.41% (191 runs sampled)
* real - strong x 1,468,073 ops/sec ±0.32% (191 runs sampled)
* real - weak x 1,446,852 ops/sec ±0.64% (190 runs sampled)
fake - strong x 635,707 ops/sec ±0.33% (194 runs sampled)
fake - weak x 627,708 ops/sec ±0.36% (192 runs sampled)
```

@@ -168,3 +162,3 @@

[node-version-image]: https://img.shields.io/node/v/etag.svg
[node-version-url]: http://nodejs.org/download/
[node-version-url]: https://nodejs.org/en/download/
[travis-image]: https://img.shields.io/travis/jshttp/etag/master.svg

@@ -171,0 +165,0 @@ [travis-url]: https://travis-ci.org/jshttp/etag

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc