Comparing version 1.1.0 to 2.0.0
{ | ||
"name": "urlencode", | ||
"version": "1.1.0", | ||
"version": "2.0.0", | ||
"description": "encodeURIComponent with charset", | ||
"main": "lib/urlencode.js", | ||
"files": [ | ||
"lib" | ||
], | ||
"scripts": { | ||
"test": "mocha -R spec -t 20000 -r should test/*.test.js", | ||
"test-cov": "istanbul cover node_modules/.bin/_mocha -- -t 20000 -r should test/*.test.js", | ||
"test-travis": "istanbul cover node_modules/.bin/_mocha --report lcovonly -- -t 20000 -r should test/*.test.js", | ||
"jshint": "jshint .", | ||
"autod": "autod -w --prefix '~' -t test -e examples", | ||
"cnpm": "npm install --registry=https://registry.npm.taobao.org", | ||
"benchmark": "node benchmark/urlencode.js && node benchmark/urlencode.decode.js" | ||
"test": "egg-bin test", | ||
"ci": "npm run lint && egg-bin cov && npm run prepublishOnly && npm run benchmark", | ||
"lint": "eslint . --ext ts", | ||
"benchmark": "node benchmark/urlencode.cjs && node benchmark/urlencode.decode.cjs", | ||
"prepublishOnly": "tshy && tshy-after" | ||
}, | ||
"dependencies": { | ||
"iconv-lite": "~0.4.11" | ||
"iconv-lite": "~0.6.3" | ||
}, | ||
"devDependencies": { | ||
"autod": "*", | ||
"beautify-benchmark": "*", | ||
"benchmark": "*", | ||
"blanket": "*", | ||
"contributors": "*", | ||
"istanbul": "~0.3.17", | ||
"jshint": "*", | ||
"mocha": "*", | ||
"should": "7" | ||
"@eggjs/tsconfig": "^1.3.3", | ||
"@types/mocha": "^10.0.3", | ||
"@types/node": "^20.8.7", | ||
"beautify-benchmark": "^0.2.4", | ||
"benchmark": "^2.1.4", | ||
"egg-bin": "^6.5.2", | ||
"eslint": "^8.51.0", | ||
"eslint-config-egg": "^13.0.0", | ||
"git-contributor": "^2.1.5", | ||
"tshy": "^1.5.0", | ||
"tshy-after": "^1.0.0", | ||
"typescript": "^5.2.2" | ||
}, | ||
@@ -46,3 +43,29 @@ "homepage": "https://github.com/node-modules/urlencode", | ||
"author": "fengmk2 <fengmk2@gmail.com>", | ||
"license": "MIT" | ||
"license": "MIT", | ||
"files": [ | ||
"dist", | ||
"src" | ||
], | ||
"tshy": { | ||
"exports": { | ||
"./package.json": "./package.json", | ||
".": "./src/index.ts" | ||
} | ||
}, | ||
"exports": { | ||
"./package.json": "./package.json", | ||
".": { | ||
"import": { | ||
"types": "./dist/esm/index.d.ts", | ||
"default": "./dist/esm/index.js" | ||
}, | ||
"require": { | ||
"types": "./dist/commonjs/index.d.ts", | ||
"default": "./dist/commonjs/index.js" | ||
} | ||
} | ||
}, | ||
"main": "./dist/commonjs/index.js", | ||
"types": "./dist/commonjs/index.d.ts", | ||
"type": "module" | ||
} |
171
README.md
@@ -1,6 +0,18 @@ | ||
urlencode [![Build Status](https://secure.travis-ci.org/node-modules/urlencode.png)](http://travis-ci.org/node-modules/urlencode) [![Coverage Status](https://coveralls.io/repos/node-modules/urlencode/badge.png)](https://coveralls.io/r/node-modules/urlencode) | ||
======= | ||
# urlencode | ||
[![NPM](https://nodei.co/npm/urlencode.png?downloads=true&stars=true)](https://nodei.co/npm/urlencode/) | ||
[![NPM version][npm-image]][npm-url] | ||
[![Node.js CI](https://github.com/node-modules/urlencode/actions/workflows/nodejs.yml/badge.svg)](https://github.com/node-modules/urllib/actions/workflows/nodejs.yml) | ||
[![Test coverage][codecov-image]][codecov-url] | ||
[![Known Vulnerabilities][snyk-image]][snyk-url] | ||
[![npm download][download-image]][download-url] | ||
[npm-image]: https://img.shields.io/npm/v/urlencode.svg?style=flat-square | ||
[npm-url]: https://npmjs.org/package/urlencode | ||
[codecov-image]: https://codecov.io/gh/node-modules/urlencode/branch/master/graph/badge.svg | ||
[codecov-url]: https://codecov.io/gh/node-modules/urlencode | ||
[snyk-image]: https://snyk.io/test/npm/urlencode/badge.svg?style=flat-square | ||
[snyk-url]: https://snyk.io/test/npm/urlencode | ||
[download-image]: https://img.shields.io/npm/dm/urlencode.svg?style=flat-square | ||
[download-url]: https://npmjs.org/package/urlencode | ||
encodeURIComponent with charset, e.g.: `gbk` | ||
@@ -11,3 +23,3 @@ | ||
```bash | ||
$ npm install urlencode | ||
npm install urlencode | ||
``` | ||
@@ -17,19 +29,18 @@ | ||
```js | ||
var urlencode = require('urlencode'); | ||
```ts | ||
import { encode, decode, parse, stringify } from 'urlencode'; | ||
console.log(urlencode('苏千')); // default is utf8 | ||
console.log(urlencode('苏千', 'gbk')); // '%CB%D5%C7%A7' | ||
console.log(encode('苏千')); // default is utf8 | ||
console.log(encode('苏千', 'gbk')); // '%CB%D5%C7%A7' | ||
// decode gbk | ||
urlencode.decode('%CB%D5%C7%A7', 'gbk'); // '苏千' | ||
decode('%CB%D5%C7%A7', 'gbk'); // '苏千' | ||
// parse gbk querystring | ||
urlencode.parse('nick=%CB%D5%C7%A7', {charset: 'gbk'}); // {nick: '苏千'} | ||
parse('nick=%CB%D5%C7%A7', { charset: 'gbk' }); // {nick: '苏千'} | ||
// stringify obj with gbk encoding | ||
var str = 'x[y][0][v][w]=' + urlencode('雾空', 'gbk'); // x[y][0][v][w]=%CE%ED%BF%D5 | ||
var str = 'x[y][0][v][w]=' + encode('雾空', 'gbk'); // x[y][0][v][w]=%CE%ED%BF%D5 | ||
var obj = {'x' : {'y' : [{'v' : {'w' : '雾空'}}]}}; | ||
urlencode.stringify(obj, {charset: 'gbk'}).should.equal(str); | ||
assert.equal(urlencode.stringify(obj, { charset: 'gbk' }, str); | ||
``` | ||
@@ -39,34 +50,130 @@ | ||
### urlencode(str, encoding) | ||
### encode(str, encoding) | ||
```bash | ||
$ node benchmark/urlencode.js | ||
$ node benchmark/urlencode.cjs | ||
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) | ||
node version: v21.1.0 | ||
"苏千测试\n, 哈哈, haha" | ||
urlencode Benchmark | ||
node version: v21.1.0, date: Sat Oct 28 2023 21:01:00 GMT+0800 (中国标准时间) | ||
Starting... | ||
4 tests completed. | ||
urlencode(str) x 4,617,242 ops/sec ±2.60% (95 runs sampled) | ||
urlencode(str, "gbk") x 1,122,430 ops/sec ±2.20% (95 runs sampled) | ||
encodeURIComponent(str) x 4,608,523 ops/sec ±2.94% (93 runs sampled) | ||
encodeUTF8(str) x 833,170 ops/sec ±1.37% (96 runs sampled) | ||
node version: v20.9.0 | ||
"苏千测试\n, 哈哈, haha" | ||
urlencode Benchmark | ||
node version: v20.9.0, date: Sat Oct 28 2023 21:01:37 GMT+0800 (中国标准时间) | ||
Starting... | ||
4 tests completed. | ||
urlencode(str) x 4,304,468 ops/sec ±2.83% (89 runs sampled) | ||
urlencode(str, "gbk") x 1,005,759 ops/sec ±2.10% (90 runs sampled) | ||
encodeURIComponent(str) x 4,289,880 ops/sec ±2.99% (92 runs sampled) | ||
encodeUTF8(str) x 827,841 ops/sec ±1.06% (96 runs sampled) | ||
node version: v18.18.0 | ||
"苏千测试\n, 哈哈, haha" | ||
urlencode Benchmark | ||
node version: v18.18.0, date: Sat Oct 28 2023 19:34:06 GMT+0800 (中国标准时间) | ||
Starting... | ||
4 tests completed. | ||
urlencode(str) x 4,597,865 ops/sec ±0.22% (96 runs sampled) | ||
urlencode(str, "gbk") x 633,620 ops/sec ±15.31% (71 runs sampled) | ||
encodeURIComponent(str) x 3,902,229 ops/sec ±2.49% (87 runs sampled) | ||
encodeUTF8(str) x 510,456 ops/sec ±26.76% (88 runs sampled) | ||
node version: v16.20.2 | ||
"苏千测试\n, 哈哈, haha" | ||
urlencode Benchmark | ||
node version: v16.20.2, date: Sat Oct 28 2023 21:02:11 GMT+0800 (中国标准时间) | ||
Starting... | ||
4 tests completed. | ||
urlencode(str) x 4,438,372 ops/sec ±1.80% (93 runs sampled) | ||
urlencode(str, "gbk") x 1,175,761 ops/sec ±0.68% (95 runs sampled) | ||
encodeURIComponent(str) x 4,374,525 ops/sec ±1.96% (97 runs sampled) | ||
encodeUTF8(str) x 751,616 ops/sec ±2.49% (86 runs sampled) | ||
``` | ||
### urlencode.decode(str, encoding) | ||
### decode(str, encoding) | ||
```bash | ||
$ node benchmark/urlencode.decode.js | ||
$ node benchmark/urlencode.decode.cjs | ||
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) | ||
``` | ||
node version: v21.1.0, date: "2023-10-28T12:51:20.191Z" | ||
## TODO | ||
urlencode.decode Benchmark | ||
node version: v21.1.0, date: Sat Oct 28 2023 20:51:20 GMT+0800 (中国标准时间) | ||
Starting... | ||
7 tests completed. | ||
* [x] stringify() | ||
urlencode.decode(str) x 515,410 ops/sec ±1.95% (91 runs sampled) | ||
urlencode.decode(str, "gbk") x 54,018 ops/sec ±3.17% (78 runs sampled) | ||
decodeURIComponent(str) x 313,204 ops/sec ±2.93% (78 runs sampled) | ||
urlencode.parse(qs, {charset: "gbk"}) x 311,613 ops/sec ±1.26% (95 runs sampled) | ||
urlencode.stringify(data, {charset: "gbk"}) x 316,558 ops/sec ±1.55% (93 runs sampled) | ||
urlencode.parse(qs, {charset: "utf8"}) x 490,744 ops/sec ±1.25% (94 runs sampled) | ||
urlencode.stringify(data, {charset: "utf8"}) x 357,206 ops/sec ±0.46% (97 runs sampled) | ||
node version: v20.9.0, date: "2023-10-28T12:49:57.236Z" | ||
urlencode.decode Benchmark | ||
node version: v20.9.0, date: Sat Oct 28 2023 20:49:57 GMT+0800 (中国标准时间) | ||
Starting... | ||
7 tests completed. | ||
urlencode.decode(str) x 573,899 ops/sec ±0.62% (95 runs sampled) | ||
urlencode.decode(str, "gbk") x 83,184 ops/sec ±0.13% (100 runs sampled) | ||
decodeURIComponent(str) x 573,371 ops/sec ±1.67% (93 runs sampled) | ||
urlencode.parse(qs, {charset: "gbk"}) x 303,202 ops/sec ±0.70% (100 runs sampled) | ||
urlencode.stringify(data, {charset: "gbk"}) x 319,546 ops/sec ±0.29% (99 runs sampled) | ||
urlencode.parse(qs, {charset: "utf8"}) x 462,578 ops/sec ±0.25% (98 runs sampled) | ||
urlencode.stringify(data, {charset: "utf8"}) x 343,487 ops/sec ±0.17% (100 runs sampled) | ||
node version: v18.18.0, date: "2023-10-28T12:44:56.355Z" | ||
urlencode.decode Benchmark | ||
node version: v18.18.0, date: Sat Oct 28 2023 20:44:56 GMT+0800 (中国标准时间) | ||
Starting... | ||
7 tests completed. | ||
urlencode.decode(str) x 550,451 ops/sec ±1.74% (98 runs sampled) | ||
urlencode.decode(str, "gbk") x 67,311 ops/sec ±1.16% (96 runs sampled) | ||
decodeURIComponent(str) x 569,461 ops/sec ±0.30% (93 runs sampled) | ||
urlencode.parse(qs, {charset: "gbk"}) x 293,407 ops/sec ±0.90% (97 runs sampled) | ||
urlencode.stringify(data, {charset: "gbk"}) x 234,162 ops/sec ±4.55% (75 runs sampled) | ||
urlencode.parse(qs, {charset: "utf8"}) x 316,697 ops/sec ±4.37% (78 runs sampled) | ||
urlencode.stringify(data, {charset: "utf8"}) x 192,787 ops/sec ±4.58% (80 runs sampled) | ||
node version: v16.20.2, date: "2023-10-28T12:47:38.431Z" | ||
urlencode.decode Benchmark | ||
node version: v16.20.2, date: Sat Oct 28 2023 20:47:38 GMT+0800 (中国标准时间) | ||
Starting... | ||
7 tests completed. | ||
urlencode.decode(str) x 537,995 ops/sec ±2.07% (96 runs sampled) | ||
urlencode.decode(str, "gbk") x 78,073 ops/sec ±0.17% (99 runs sampled) | ||
decodeURIComponent(str) x 558,509 ops/sec ±0.48% (96 runs sampled) | ||
urlencode.parse(qs, {charset: "gbk"}) x 252,590 ops/sec ±2.87% (90 runs sampled) | ||
urlencode.stringify(data, {charset: "gbk"}) x 287,978 ops/sec ±2.47% (92 runs sampled) | ||
urlencode.parse(qs, {charset: "utf8"}) x 416,600 ops/sec ±0.72% (93 runs sampled) | ||
urlencode.stringify(data, {charset: "utf8"}) x 281,319 ops/sec ±2.43% (85 runs sampled) | ||
``` | ||
## License | ||
[MIT](LICENSE.txt) |
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
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
44858
10
619
177
Yes
12
1
+ Addediconv-lite@0.6.3(transitive)
- Removediconv-lite@0.4.24(transitive)
Updatediconv-lite@~0.6.3