Comparing version 1.1.1 to 1.1.2
@@ -0,1 +1,6 @@ | ||
1.1.2 / 2017-09-23 | ||
================== | ||
* perf: improve header token parsing speed | ||
1.1.1 / 2017-03-20 | ||
@@ -2,0 +7,0 @@ ================== |
34
index.js
@@ -17,9 +17,2 @@ /*! | ||
/** | ||
* Regular expression to split on commas, trimming spaces | ||
* @private | ||
*/ | ||
var ARRAY_SPLIT_REGEXP = / *, */ | ||
/** | ||
* RegExp to match field-name in RFC 7230 sec 3.2 | ||
@@ -105,3 +98,28 @@ * | ||
function parse (header) { | ||
return header.trim().split(ARRAY_SPLIT_REGEXP) | ||
var end = 0 | ||
var list = [] | ||
var start = 0 | ||
// gather tokens | ||
for (var i = 0, len = header.length; i < len; i++) { | ||
switch (header.charCodeAt(i)) { | ||
case 0x20: /* */ | ||
if (start === end) { | ||
start = end = i + 1 | ||
} | ||
break | ||
case 0x2c: /* , */ | ||
list.push(header.substring(start, end)) | ||
start = end = i + 1 | ||
break | ||
default: | ||
end = i + 1 | ||
break | ||
} | ||
} | ||
// final token | ||
list.push(header.substring(start, end)) | ||
return list | ||
} | ||
@@ -108,0 +126,0 @@ |
{ | ||
"name": "vary", | ||
"description": "Manipulate the HTTP Vary header", | ||
"version": "1.1.1", | ||
"version": "1.1.2", | ||
"author": "Douglas Christopher Wilson <doug@somethingdoug.com>", | ||
@@ -14,7 +14,11 @@ "license": "MIT", | ||
"devDependencies": { | ||
"eslint": "3.18.0", | ||
"eslint-config-standard": "7.1.0", | ||
"eslint-plugin-markdown": "1.0.0-beta.4", | ||
"beautify-benchmark": "0.2.4", | ||
"benchmark": "2.1.4", | ||
"eslint": "3.19.0", | ||
"eslint-config-standard": "10.2.1", | ||
"eslint-plugin-import": "2.7.0", | ||
"eslint-plugin-markdown": "1.0.0-beta.6", | ||
"eslint-plugin-node": "5.1.1", | ||
"eslint-plugin-promise": "3.5.0", | ||
"eslint-plugin-standard": "2.1.1", | ||
"eslint-plugin-standard": "3.0.1", | ||
"istanbul": "0.4.5", | ||
@@ -34,2 +38,3 @@ "mocha": "2.5.3", | ||
"scripts": { | ||
"bench": "node benchmark/index.js", | ||
"lint": "eslint --plugin markdown --ext js,md .", | ||
@@ -36,0 +41,0 @@ "test": "mocha --reporter spec --bail --check-leaks test/", |
8747
124
12