-
-
Notifications
You must be signed in to change notification settings - Fork 160
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c1a8b8f
commit 9f2ca12
Showing
2 changed files
with
54 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,18 +10,14 @@ Basic HTTP cookie parser and serializer for HTTP servers. | |
|
||
## 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 | ||
$ npm install cookie | ||
``` | ||
|
||
## API | ||
|
||
```js | ||
var cookie = require("cookie"); | ||
const cookie = require("cookie"); | ||
``` | ||
|
||
### cookie.parse(str, options) | ||
|
@@ -31,7 +27,7 @@ The `str` argument is the string representing a `Cookie` header value and `optio | |
optional object containing additional parsing options. | ||
|
||
```js | ||
var cookies = cookie.parse("foo=bar; equation=E%3Dmc%5E2"); | ||
const cookies = cookie.parse("foo=bar; equation=E%3Dmc%5E2"); | ||
// { foo: 'bar', equation: 'E=mc^2' } | ||
``` | ||
|
||
|
@@ -58,7 +54,7 @@ name for the cookie, the `value` argument is the value to set the cookie to, and | |
argument is an optional object containing additional serialization options. | ||
|
||
```js | ||
var setCookie = cookie.serialize("foo", "bar"); | ||
const setCookie = cookie.serialize("foo", "bar"); | ||
// foo=bar | ||
``` | ||
|
||
|
@@ -220,73 +216,40 @@ http.createServer(onRequest).listen(3000); | |
## Testing | ||
|
||
```sh | ||
$ npm test | ||
npm test | ||
``` | ||
|
||
## Benchmark | ||
|
||
```sh | ||
npm run bench | ||
``` | ||
|
||
``` | ||
$ npm run bench | ||
> [email protected] bench | ||
> node benchmark/index.js | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
modules@108 | ||
napi@9 | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
[email protected]+quic | ||
[email protected] | ||
tz@2023c | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
> node benchmark/parse-top.js | ||
cookie.parse - top sites | ||
14 tests completed. | ||
parse accounts.google.com x 2,588,913 ops/sec ±0.74% (186 runs sampled) | ||
parse apple.com x 2,370,002 ops/sec ±0.69% (186 runs sampled) | ||
parse cloudflare.com x 2,213,102 ops/sec ±0.88% (188 runs sampled) | ||
parse docs.google.com x 2,194,157 ops/sec ±1.03% (184 runs sampled) | ||
parse drive.google.com x 2,265,084 ops/sec ±0.79% (187 runs sampled) | ||
parse en.wikipedia.org x 457,099 ops/sec ±0.81% (186 runs sampled) | ||
parse linkedin.com x 504,407 ops/sec ±0.89% (186 runs sampled) | ||
parse maps.google.com x 1,230,959 ops/sec ±0.98% (186 runs sampled) | ||
parse microsoft.com x 926,294 ops/sec ±0.88% (184 runs sampled) | ||
parse play.google.com x 2,311,338 ops/sec ±0.83% (185 runs sampled) | ||
parse support.google.com x 1,508,850 ops/sec ±0.86% (186 runs sampled) | ||
parse www.google.com x 1,022,582 ops/sec ±1.32% (182 runs sampled) | ||
parse youtu.be x 332,136 ops/sec ±1.02% (185 runs sampled) | ||
parse youtube.com x 323,833 ops/sec ±0.77% (183 runs sampled) | ||
> node benchmark/parse.js | ||
cookie.parse - generic | ||
6 tests completed. | ||
simple x 3,214,032 ops/sec ±1.61% (183 runs sampled) | ||
decode x 587,237 ops/sec ±1.16% (187 runs sampled) | ||
unquote x 2,954,618 ops/sec ±1.35% (183 runs sampled) | ||
duplicates x 857,008 ops/sec ±0.89% (187 runs sampled) | ||
10 cookies x 292,133 ops/sec ±0.89% (187 runs sampled) | ||
100 cookies x 22,610 ops/sec ±0.68% (187 runs sampled) | ||
name hz min max mean p75 p99 p995 p999 rme samples | ||
· simple 8,566,313.09 0.0000 0.3694 0.0001 0.0001 0.0002 0.0002 0.0003 ±0.64% 4283157 fastest | ||
· decode 3,834,348.85 0.0001 0.2465 0.0003 0.0003 0.0003 0.0004 0.0006 ±0.38% 1917175 | ||
· unquote 8,315,355.96 0.0000 0.3824 0.0001 0.0001 0.0002 0.0002 0.0003 ±0.72% 4157880 | ||
· duplicates 1,944,765.97 0.0004 0.2959 0.0005 0.0005 0.0006 0.0006 0.0008 ±0.24% 972384 | ||
· 10 cookies 675,345.67 0.0012 0.4328 0.0015 0.0015 0.0019 0.0020 0.0058 ±0.75% 337673 | ||
· 100 cookies 61,040.71 0.0152 0.4092 0.0164 0.0160 0.0196 0.0228 0.2260 ±0.71% 30521 slowest | ||
✓ parse top-sites (15) 22945ms | ||
name hz min max mean p75 p99 p995 p999 rme samples | ||
· parse accounts.google.com 7,164,349.17 0.0000 0.0929 0.0001 0.0002 0.0002 0.0002 0.0003 ±0.09% 3582184 | ||
· parse apple.com 7,817,686.84 0.0000 0.6048 0.0001 0.0001 0.0002 0.0002 0.0003 ±1.05% 3908844 | ||
· parse cloudflare.com 7,189,841.70 0.0000 0.0390 0.0001 0.0002 0.0002 0.0002 0.0003 ±0.06% 3594921 | ||
· parse docs.google.com 7,051,765.61 0.0000 0.0296 0.0001 0.0002 0.0002 0.0002 0.0003 ±0.06% 3525883 | ||
· parse drive.google.com 7,349,104.77 0.0000 0.0368 0.0001 0.0001 0.0002 0.0002 0.0003 ±0.05% 3674553 | ||
· parse en.wikipedia.org 1,929,909.49 0.0004 0.3598 0.0005 0.0005 0.0007 0.0007 0.0012 ±0.16% 964955 | ||
· parse linkedin.com 2,225,658.01 0.0003 0.0595 0.0004 0.0005 0.0005 0.0005 0.0006 ±0.06% 1112830 | ||
· parse maps.google.com 4,423,511.68 0.0001 0.0942 0.0002 0.0003 0.0003 0.0003 0.0005 ±0.08% 2211756 | ||
· parse microsoft.com 3,387,601.88 0.0002 0.0725 0.0003 0.0003 0.0004 0.0004 0.0005 ±0.09% 1693801 | ||
· parse play.google.com 7,375,980.86 0.0000 0.1994 0.0001 0.0001 0.0002 0.0002 0.0003 ±0.12% 3687991 | ||
· parse support.google.com 4,912,267.94 0.0001 2.8958 0.0002 0.0002 0.0003 0.0003 0.0005 ±1.28% 2456134 | ||
· parse www.google.com 3,443,035.87 0.0002 0.2783 0.0003 0.0003 0.0004 0.0004 0.0007 ±0.51% 1721518 | ||
· parse youtu.be 1,910,492.87 0.0004 0.3490 0.0005 0.0005 0.0007 0.0007 0.0011 ±0.46% 955247 | ||
· parse youtube.com 1,895,082.62 0.0004 0.7454 0.0005 0.0005 0.0006 0.0007 0.0013 ±0.64% 947542 slowest | ||
· parse example.com 21,582,835.27 0.0000 0.1095 0.0000 0.0000 0.0001 0.0001 0.0001 ±0.13% 10791418 | ||
``` | ||
|
||
## References | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters