base128-ascii 2.2.0 → 3.0.0
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.
- package/main.d.ts +9 -5
- package/main.js +5 -11
- package/package.json +2 -2
package/main.d.ts
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
|
-
export declare class
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
export declare class Base128Bytes extends Uint8Array {
|
|
2
|
+
/**
|
|
3
|
+
* Returns a base128 string.
|
|
4
|
+
*/
|
|
4
5
|
toString(): string;
|
|
6
|
+
/**
|
|
7
|
+
* Returns a base128 [Template literals](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Template_literals).
|
|
8
|
+
*/
|
|
5
9
|
toJSTemplateLiterals(): string;
|
|
6
10
|
}
|
|
7
|
-
export declare function encode(input: Uint8Array | string):
|
|
11
|
+
export declare function encode(input: Uint8Array | string): Base128Bytes;
|
|
8
12
|
export declare function decode(input: string): Uint8Array;
|
|
9
13
|
declare const base128: {
|
|
10
|
-
|
|
14
|
+
Base128Bytes: typeof Base128Bytes;
|
|
11
15
|
encode: typeof encode;
|
|
12
16
|
decode: typeof decode;
|
|
13
17
|
};
|
package/main.js
CHANGED
|
@@ -1,14 +1,8 @@
|
|
|
1
1
|
//@ts-nocheck
|
|
2
2
|
|
|
3
|
-
export class
|
|
4
|
-
/**
|
|
5
|
-
* @param {Uint8Array} out
|
|
6
|
-
*/
|
|
7
|
-
constructor(out) {
|
|
8
|
-
this.uint8Array = out
|
|
9
|
-
}
|
|
3
|
+
export class Base128Bytes extends Uint8Array {
|
|
10
4
|
toString() {
|
|
11
|
-
return new TextDecoder().decode(this
|
|
5
|
+
return new TextDecoder().decode(this)
|
|
12
6
|
}
|
|
13
7
|
toJSTemplateLiterals() {
|
|
14
8
|
return `\`${this.toString().replace(
|
|
@@ -31,7 +25,7 @@ export function encode(input) {
|
|
|
31
25
|
if (typeof input == 'string')
|
|
32
26
|
input = new TextEncoder().encode(input)
|
|
33
27
|
var il = input.length
|
|
34
|
-
, out = new
|
|
28
|
+
, out = new Base128Bytes(Math.ceil(il / 7 * 8))
|
|
35
29
|
, ii = 0
|
|
36
30
|
, oi = 0
|
|
37
31
|
while (ii < il) {
|
|
@@ -48,7 +42,7 @@ export function encode(input) {
|
|
|
48
42
|
/* 6 */ out[oi++] = (input[ii++] << 1 | input[ii] >> 7) & 127
|
|
49
43
|
/* 7 */ out[oi++] = input[ii++] & 127
|
|
50
44
|
}
|
|
51
|
-
return
|
|
45
|
+
return out
|
|
52
46
|
}
|
|
53
47
|
|
|
54
48
|
/**
|
|
@@ -82,7 +76,7 @@ export function decode(input) {
|
|
|
82
76
|
}
|
|
83
77
|
|
|
84
78
|
export default {
|
|
85
|
-
|
|
79
|
+
Base128Bytes,
|
|
86
80
|
encode,
|
|
87
81
|
decode
|
|
88
82
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "base128-ascii",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"author": "bddjr",
|
|
5
5
|
"license": "Unlicense",
|
|
6
6
|
"type": "module",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"main.d.ts"
|
|
11
11
|
],
|
|
12
12
|
"scripts": {
|
|
13
|
-
"test": "es-check es6 --checkFeatures --module
|
|
13
|
+
"test": "es-check es6 --checkFeatures --module main.js && node scripts/test.mjs",
|
|
14
14
|
"prepublishOnly": "node --run test"
|
|
15
15
|
},
|
|
16
16
|
"repository": {
|