Comparing version 0.2.0 to 1.0.0
@@ -20,3 +20,3 @@ /**! | ||
console.log('node version: %s', process.version); | ||
console.log('node version: %s, date: %j', process.version, new Date()); | ||
@@ -41,2 +41,7 @@ var suite = new Benchmark.Suite(); | ||
var gbkEncodeString = 'umidtoken=Tc230acc03a564530aee31d22701e9b95&usertag4=0&usertag3=512&usertag2=0&status=0&userid=665377421&out_user=suqian.yf%40taobao.com&promotedtype=0&account_no=20885028063394350156&loginstatus=true&usertag=0&nick=%CB%D5%C7%A7&tairlastupdatetime=1319008872&strid=a68f6ee38f44d2b89ca508444c1ccaf9'; | ||
var data = urlencode.parse(gbkEncodeString, {charset: 'gbk'}); | ||
// console.log(urlencode.stringify(data, {charset: 'gbk'}) === gbkEncodeString); | ||
suite | ||
@@ -66,6 +71,9 @@ | ||
.add('urlencode.parse(qs, {charset: "gbk"})', function () { | ||
urlencode.parse('umidtoken=Tc230acc03a564530aee31d22701e9b95&usertag4=0&usertag3=512&usertag2=0&status=0&userid=665377421&out_user=suqian.yf%40taobao.com&promotedtype=0&account_no=20885028063394350156&loginstatus=true&usertag=0&nick=%CB%D5%C7%A7&tairlastupdatetime=1319008872&strid=a68f6ee38f44d2b89ca508444c1ccaf9', | ||
{charset: 'gbk'}); | ||
urlencode.parse(gbkEncodeString, {charset: 'gbk'}); | ||
}) | ||
.add('urlencode.stringify(data, {charset: "gbk"})', function () { | ||
urlencode.stringify(data, {charset: 'gbk'}); | ||
}) | ||
.add('urlencode.parse(qs, {charset: "utf8"})', function () { | ||
@@ -76,2 +84,6 @@ urlencode.parse('umidtoken=Tc230acc03a564530aee31d22701e9b95&usertag4=0&usertag3=512&usertag2=0&status=0&userid=665377421&out_user=suqian.yf%40taobao.com&promotedtype=0&account_no=20885028063394350156&loginstatus=true&usertag=0&nick=%E8%8B%8F%E5%8D%83&tairlastupdatetime=1319008872&strid=a68f6ee38f44d2b89ca508444c1ccaf9', | ||
.add('urlencode.stringify(data, {charset: "utf8"})', function () { | ||
urlencode.stringify(data, {charset: 'utf8'}); | ||
}) | ||
// add listeners | ||
@@ -85,2 +97,1 @@ .on('cycle', function (event) { | ||
.run(); | ||
@@ -14,2 +14,3 @@ /*! | ||
var Benchmark = require('benchmark'); | ||
var benchmarks = require('beautify-benchmark'); | ||
var urlencode = require('../'); | ||
@@ -19,2 +20,13 @@ | ||
function encodeUTF8(str) { | ||
var encodeStr = ''; | ||
var buf = new Buffer(str); | ||
for (var i = 0; i < buf.length; i++) { | ||
encodeStr += '%' + buf[i].toString('16'); | ||
} | ||
return encodeStr.toUpperCase(); | ||
} | ||
console.log(decodeURIComponent(encodeUTF8('苏千测试, 哈哈, haha'))); | ||
var suite = new Benchmark.Suite(); | ||
@@ -25,30 +37,68 @@ | ||
.add('urlencode(str)', function () { | ||
urlencode('苏千'); | ||
// urlencode('苏千'); | ||
urlencode('苏千写的urlencode,应该有用'); | ||
urlencode('suqian want to sleep early tonight.'); | ||
urlencode('你让同一个项目中写两份一样代码的人情何以堪呢,你让同一个项目中写两份一样代码的人情何以堪呢,你让同一个项目中写两份一样代码的人情何以堪呢,你让同一个项目中写两份一样代码的人情何以堪呢'); | ||
// urlencode('suqian want to sleep early tonight.'); | ||
// urlencode('你让同一个项目中写两份一样代码的人情何以堪呢,你让同一个项目中写两份一样代码的人情何以堪呢,你让同一个项目中写两份一样代码的人情何以堪呢,你让同一个项目中写两份一样代码的人情何以堪呢'); | ||
}) | ||
.add('urlencode(str, "gbk")', function () { | ||
urlencode('苏千', 'gbk'); | ||
// urlencode('苏千', 'gbk'); | ||
urlencode('苏千写的urlencode,应该有用', 'gbk'); | ||
urlencode('suqian want to sleep early tonight.', 'gbk'); | ||
urlencode('你让同一个项目中写两份一样代码的人情何以堪呢,你让同一个项目中写两份一样代码的人情何以堪呢,你让同一个项目中写两份一样代码的人情何以堪呢,你让同一个项目中写两份一样代码的人情何以堪呢', 'gbk'); | ||
// urlencode('suqian want to sleep early tonight.', 'gbk'); | ||
// urlencode('你让同一个项目中写两份一样代码的人情何以堪呢,你让同一个项目中写两份一样代码的人情何以堪呢,你让同一个项目中写两份一样代码的人情何以堪呢,你让同一个项目中写两份一样代码的人情何以堪呢', 'gbk'); | ||
}) | ||
.add('encodeURIComponent(str)', function () { | ||
encodeURIComponent('苏千'); | ||
// encodeURIComponent('苏千'); | ||
encodeURIComponent('苏千写的urlencode,应该有用'); | ||
encodeURIComponent('suqian want to sleep early tonight.'); | ||
encodeURIComponent('你让同一个项目中写两份一样代码的人情何以堪呢,你让同一个项目中写两份一样代码的人情何以堪呢,你让同一个项目中写两份一样代码的人情何以堪呢,你让同一个项目中写两份一样代码的人情何以堪呢'); | ||
// encodeURIComponent('suqian want to sleep early tonight.'); | ||
// encodeURIComponent('你让同一个项目中写两份一样代码的人情何以堪呢,你让同一个项目中写两份一样代码的人情何以堪呢,你让同一个项目中写两份一样代码的人情何以堪呢,你让同一个项目中写两份一样代码的人情何以堪呢'); | ||
}) | ||
// add listeners | ||
.on('cycle', function (event) { | ||
console.log(String(event.target)); | ||
.add('encodeUTF8(str)', function () { | ||
// encodeUTF8('苏千'); | ||
encodeUTF8('苏千写的urlencode,应该有用'); | ||
// encodeUTF8('suqian want to sleep early tonight.'); | ||
// encodeUTF8('你让同一个项目中写两份一样代码的人情何以堪呢,你让同一个项目中写两份一样代码的人情何以堪呢,你让同一个项目中写两份一样代码的人情何以堪呢,你让同一个项目中写两份一样代码的人情何以堪呢'); | ||
}) | ||
.on('complete', function () { | ||
console.log('Fastest is ' + this.filter('fastest').pluck('name')); | ||
.on('cycle', function(event) { | ||
benchmarks.add(event.target); | ||
}) | ||
.run(); | ||
.on('start', function(event) { | ||
console.log('\n urlencode Benchmark\n node version: %s, date: %s\n Starting...', | ||
process.version, Date()); | ||
}) | ||
.on('complete', function done() { | ||
benchmarks.log(); | ||
}) | ||
.run({ 'async': false }); | ||
// $ node benchmark/urlencode.js | ||
// | ||
// node version: v0.11.12 | ||
// | ||
// urlencode Benchmark | ||
// node version: v0.11.12, date: Sat Aug 23 2014 23:15:27 GMT+0800 (CST) | ||
// Starting... | ||
// 4 tests completed. | ||
// | ||
// urlencode(str) x 427,364 ops/sec ±3.46% (93 runs sampled) | ||
// urlencode(str, "gbk") x 80,073 ops/sec ±1.92% (91 runs sampled) | ||
// encodeURIComponent(str) x 453,495 ops/sec ±0.78% (97 runs sampled) | ||
// encodeUTF8(str) x 117,744 ops/sec ±0.83% (100 runs sampled) | ||
// $ node benchmark/urlencode.js | ||
// | ||
// node version: v0.11.14 | ||
// 苏千测试, 哈哈, haha | ||
// | ||
// urlencode Benchmark | ||
// node version: v0.11.14, date: Fri Sep 26 2014 10:50:01 GMT+0800 (CST) | ||
// Starting... | ||
// 4 tests completed. | ||
// | ||
// urlencode(str) x 378,559 ops/sec ±4.10% (85 runs sampled) | ||
// urlencode(str, "gbk") x 104,806 ops/sec ±3.64% (85 runs sampled) | ||
// encodeURIComponent(str) x 328,671 ops/sec ±5.99% (76 runs sampled) | ||
// encodeUTF8(str) x 75,077 ops/sec ±6.34% (77 runs sampled) |
1.0.0 / 2015-04-04 | ||
================== | ||
* deps: upgrade iconv-lite to 0.4.7 | ||
0.2.0 / 2014-04-25 | ||
@@ -3,0 +8,0 @@ ================== |
{ | ||
"name": "urlencode", | ||
"version": "0.2.0", | ||
"version": "1.0.0", | ||
"description": "encodeURIComponent with charset", | ||
@@ -16,7 +16,8 @@ "main": "index.js", | ||
"dependencies": { | ||
"iconv-lite": "0.2.11", | ||
"utility": "0.1.13" | ||
"iconv-lite": "~0.4.7", | ||
"utility": "~1.3.0" | ||
}, | ||
"devDependencies": { | ||
"autod": "*", | ||
"beautify-benchmark": "*", | ||
"benchmark": "*", | ||
@@ -29,3 +30,3 @@ "blanket": "*", | ||
"mocha-lcov-reporter": "*", | ||
"should": "3.3.1", | ||
"should": "~5.2.0", | ||
"travis-cov": "*" | ||
@@ -32,0 +33,0 @@ }, |
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
18527
358
0
11
+ Addedcopy-to@2.0.1(transitive)
+ Addediconv-lite@0.4.24(transitive)
+ Addedsafer-buffer@2.1.2(transitive)
+ Addedutility@1.3.2(transitive)
- Removedaddress@2.0.3(transitive)
- Removediconv-lite@0.2.11(transitive)
- Removedutility@0.1.13(transitive)
Updatediconv-lite@~0.4.7
Updatedutility@~1.3.0