Comparing version 0.1.0 to 0.1.1
/*! | ||
* urlencode - benchmark/urlencode.js | ||
* Copyright(c) 2012 fengmk2 <fengmk2@gmail.com> | ||
* Copyright(c) 2012 - 2014 fengmk2 <fengmk2@gmail.com> | ||
* MIT Licensed | ||
@@ -16,2 +16,4 @@ */ | ||
console.log('node version: %s', process.version); | ||
var suite = new Benchmark.Suite(); | ||
@@ -18,0 +20,0 @@ |
0.1.1 / 2014-02-25 | ||
================== | ||
* improve parse() performance 10x | ||
0.1.0 / 2014-02-24 | ||
@@ -3,0 +8,0 @@ ================== |
@@ -110,10 +110,22 @@ /**! | ||
try { | ||
k = decode(kstr, charset); | ||
v = decode(vstr, charset); | ||
} catch (e) { | ||
k = QueryString.unescape(kstr, true); | ||
v = QueryString.unescape(vstr, true); | ||
if (kstr && kstr.indexOf('%') >= 0) { | ||
try { | ||
k = decode(kstr, charset); | ||
} catch (e) { | ||
k = kstr; | ||
} | ||
} else { | ||
k = kstr; | ||
} | ||
if (vstr && vstr.indexOf('%') >= 0) { | ||
try { | ||
v = decode(vstr, charset); | ||
} catch (e) { | ||
v = vstr; | ||
} | ||
} else { | ||
v = vstr; | ||
} | ||
if (!utility.hasOwnProperty(obj, k)) { | ||
@@ -120,0 +132,0 @@ obj[k] = v; |
{ | ||
"name": "urlencode", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "encodeURIComponent with charset", | ||
@@ -20,2 +20,3 @@ "main": "index.js", | ||
"devDependencies": { | ||
"contributors": "*", | ||
"autod": "*", | ||
@@ -39,3 +40,5 @@ "benchmark": "*", | ||
"encodeURIComponent", | ||
"decodeURIComponent" | ||
"decodeURIComponent", | ||
"querystring", | ||
"parse" | ||
], | ||
@@ -42,0 +45,0 @@ "author": "fengmk2 <fengmk2@gmail.com>", |
@@ -8,10 +8,8 @@ urlencode [![Build Status](https://secure.travis-ci.org/fengmk2/urlencode.png)](http://travis-ci.org/fengmk2/urlencode) [![Coverage Status](https://coveralls.io/repos/fengmk2/urlencode/badge.png)](https://coveralls.io/r/fengmk2/urlencode) | ||
encodeURIComponent with charset. | ||
encodeURIComponent with charset, e.g.: `gbk` | ||
jscoverage: [100%](http://fengmk2.github.com/coverage/urlencode.html) | ||
## Install | ||
```bash | ||
$ npm install urlencode | ||
$ npm install urlencode --registry=http://r.cnpmjs.org | ||
``` | ||
@@ -31,3 +29,3 @@ | ||
// parse gbk querystring | ||
urlencode.parse('nick=%CB%D5%C7%A7', 'gbk'); // {nick: '苏千'} | ||
urlencode.parse('nick=%CB%D5%C7%A7', {charset: 'gbk'}); // {nick: '苏千'} | ||
``` | ||
@@ -37,10 +35,32 @@ | ||
### urlencode(str, encoding) | ||
```bash | ||
$ make benchmark | ||
urlencode(str) x 11,931 ops/sec ±0.85% (89 runs sampled) | ||
urlencode(str, "gbk") x 7,516 ops/sec ±2.67% (90 runs sampled) | ||
encodeURIComponent(str) x 11,723 ops/sec ±3.93% (91 runs sampled) | ||
Fastest is urlencode(str),encodeURIComponent(str) | ||
$ node benchmark/urlencode.js | ||
node version: v0.10.26 | ||
urlencode(str) x 11,980 ops/sec ±1.13% (100 runs sampled) | ||
urlencode(str, "gbk") x 8,575 ops/sec ±1.58% (94 runs sampled) | ||
encodeURIComponent(str) x 11,677 ops/sec ±2.32% (93 runs sampled) | ||
Fastest is urlencode(str) | ||
``` | ||
### urlencode.decode(str, encoding) | ||
```bash | ||
$ node benchmark/urlencode.decode.js | ||
node version: v0.10.26 | ||
urlencode.decode(str) x 26,027 ops/sec ±7.51% (73 runs sampled) | ||
urlencode.decode(str, "gbk") x 14,409 ops/sec ±1.72% (98 runs sampled) | ||
decodeURIComponent(str) x 36,052 ops/sec ±0.90% (96 runs sampled) | ||
urlencode.parse(qs, {charset: "gbk"}) x 16,401 ops/sec ±1.09% (98 runs sampled) | ||
urlencode.parse(qs, {charset: "utf8"}) x 23,381 ops/sec ±2.22% (93 runs sampled) | ||
Fastest is decodeURIComponent(str) | ||
``` | ||
## TODO | ||
* [ ] stringify() | ||
## License | ||
@@ -47,0 +67,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
24391
12
236
87
0
9