base128-ascii 5.0.5 → 5.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +13 -11
  2. package/main.js +5 -7
  3. package/package.json +10 -5
package/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  Smaller than base64, only use ASCII, can run in web browser.
2
2
 
3
- Build for [vite-plugin-singlefile-compression](https://github.com/bddjr/vite-plugin-singlefile-compression)
3
+ Build for [vite-plugin-singlefile-compression](https://bddjr.github.io/vite-plugin-singlefile-compression/#/)
4
+
5
+ Preview: https://bddjr.github.io/base128/
4
6
 
5
7
  ## Setup
6
8
 
@@ -30,12 +32,12 @@ screenshot-45.519.jpg
30
32
  file length: 682086
31
33
 
32
34
  base128:
33
- time encode: 7.306ms
34
- time toString: 0.168ms
35
- time toJSTemplateLiterals: 1.876ms
35
+ time encode: 10.177ms
36
+ time toString: 2.107ms
37
+ time toJSTemplateLiterals: 11.586ms
36
38
  toJSTemplateLiterals length: 796961
37
- time eval: 6.242ms
38
- time decode: 10.614ms
39
+ time eval: 5.97ms
40
+ time decode: 4.436ms
39
41
  equal: true
40
42
 
41
43
  base64:
@@ -49,12 +51,12 @@ Encode `50MB` file, use base128 is `8180525 Bytes` smaller than base64:
49
51
  file length: 50000000
50
52
 
51
53
  base128:
52
- time encode: 67.717ms
53
- time toString: 10.025ms
54
- time toJSTemplateLiterals: 197.364ms
54
+ time encode: 69.156ms
55
+ time toString: 10.252ms
56
+ time toJSTemplateLiterals: 148.9ms
55
57
  toJSTemplateLiterals length: 58486143
56
- time eval: 1.083s
57
- time decode: 171.262ms
58
+ time eval: 1.046s
59
+ time decode: 183.151ms
58
60
  equal: true
59
61
 
60
62
  base64:
package/main.js CHANGED
@@ -81,6 +81,9 @@ export function encode(input) {
81
81
  * @param {string} input
82
82
  */
83
83
  export function decode(input) {
84
+ // 0 1 2 3 4 5 6 7
85
+ // in _0000000 _1111111 _2222222 _3333333 _4444444 _5555555 _6666666 _7777777
86
+ // out 00000001 11111122 22222333 33334444 44455555 55666666 67777777
84
87
  var il = input.length
85
88
  , out = new Uint8Array(il / 8 * 7)
86
89
  , ii = 0
@@ -91,13 +94,8 @@ export function decode(input) {
91
94
  (cache = input.charCodeAt(ii++)) >> 7
92
95
  ? cache = 0 // In HTML, 0 is likely to be converted to 65533 (�)
93
96
  : cache
94
- while (ii < il) {
95
- // 0 1 2 3 4 5 6 7
96
- // in _0000000 _1111111 _2222222 _3333333 _4444444 _5555555 _6666666 _7777777
97
- // out 00000001 11111122 22222333 33334444 44455555 55666666 67777777
98
- k || next(k = 7)
99
- out[oi++] = cache << 8 - k | next() >> --k
100
- }
97
+ for (; ii < il; out[oi++] = cache << 8 - k | next() >> --k)
98
+ k || next(k = 7);
101
99
  return out
102
100
  }
103
101
 
package/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "base128-ascii",
3
- "version": "5.0.5",
3
+ "version": "5.0.6",
4
4
  "author": "bddjr",
5
+ "description": "Smaller than base64, only use ASCII, can run in web browser.",
5
6
  "license": "Unlicense",
6
7
  "type": "module",
7
8
  "main": "./main.js",
@@ -10,8 +11,9 @@
10
11
  "main.d.ts"
11
12
  ],
12
13
  "scripts": {
13
- "test": "es-check es6 --checkFeatures --module main.js && tsc && node scripts/test.mjs",
14
- "test:deno": "deno run --allow-read=. --allow-write=. scripts/test.mjs",
14
+ "check": "es-check es6 --checkFeatures --module main.js && tsc",
15
+ "test": "node --run check && node scripts/test.mjs",
16
+ "test:deno": "deno run --allow-all scripts/test.mjs",
15
17
  "test:bun": "bun scripts/test.mjs",
16
18
  "prepublishOnly": "node --run test"
17
19
  },
@@ -19,6 +21,7 @@
19
21
  "type": "git",
20
22
  "url": "git+https://github.com/bddjr/base128.git"
21
23
  },
24
+ "homepage": "https://bddjr.github.io/base128/",
22
25
  "keywords": [
23
26
  "base128",
24
27
  "base64",
@@ -27,10 +30,12 @@
27
30
  "encode",
28
31
  "decode",
29
32
  "atob",
30
- "btoa"
33
+ "btoa",
34
+ "base128-ascii",
35
+ "base128jstl"
31
36
  ],
32
37
  "devDependencies": {
33
38
  "es-check": "^9.5.3",
34
39
  "typescript": "^6.0.3"
35
40
  }
36
- }
41
+ }