@thi.ng/leb128 3.1.3 → 3.1.4
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/CHANGELOG.md +7 -1
- package/README.md +2 -2
- package/index.js +14 -14
- package/package.json +9 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
-
- **Last updated**: 2024-
|
|
3
|
+
- **Last updated**: 2024-06-21T19:34:38Z
|
|
4
4
|
- **Generator**: [thi.ng/monopub](https://thi.ng/monopub)
|
|
5
5
|
|
|
6
6
|
All notable changes to this project will be documented in this file.
|
|
@@ -9,6 +9,12 @@ See [Conventional Commits](https://conventionalcommits.org/) for commit guidelin
|
|
|
9
9
|
**Note:** Unlisted _patch_ versions only involve non-code or otherwise excluded changes
|
|
10
10
|
and/or version bumps of transitive dependencies.
|
|
11
11
|
|
|
12
|
+
### [3.1.4](https://github.com/thi-ng/umbrella/tree/@thi.ng/leb128@3.1.4) (2024-06-21)
|
|
13
|
+
|
|
14
|
+
#### ♻️ Refactoring
|
|
15
|
+
|
|
16
|
+
- enforce uniform naming convention of internal functions ([56992b2](https://github.com/thi-ng/umbrella/commit/56992b2))
|
|
17
|
+
|
|
12
18
|
## [3.1.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/leb128@3.1.0) (2024-04-20)
|
|
13
19
|
|
|
14
20
|
#### 🚀 Features
|
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
[](https://mastodon.thi.ng/@toxi)
|
|
8
8
|
|
|
9
9
|
> [!NOTE]
|
|
10
|
-
> This is one of
|
|
10
|
+
> This is one of 193 standalone projects, maintained as part
|
|
11
11
|
> of the [@thi.ng/umbrella](https://github.com/thi-ng/umbrella/) monorepo
|
|
12
12
|
> and anti-framework.
|
|
13
13
|
>
|
|
@@ -89,7 +89,7 @@ For Node.js REPL:
|
|
|
89
89
|
const leb = await import("@thi.ng/leb128");
|
|
90
90
|
```
|
|
91
91
|
|
|
92
|
-
Package sizes (brotli'd, pre-treeshake): ESM:
|
|
92
|
+
Package sizes (brotli'd, pre-treeshake): ESM: 967 bytes
|
|
93
93
|
|
|
94
94
|
## Dependencies
|
|
95
95
|
|
package/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { hasWASM } from "@thi.ng/checks/has-wasm";
|
|
2
|
-
import { unsupported } from "@thi.ng/errors/unsupported";
|
|
3
2
|
import { ensureIndex } from "@thi.ng/errors/out-of-bounds";
|
|
3
|
+
import { unsupported } from "@thi.ng/errors/unsupported";
|
|
4
4
|
import { base64Decode } from "@thi.ng/transducers-binary/base64";
|
|
5
5
|
import { BINARY } from "./binary.js";
|
|
6
6
|
let wasm;
|
|
@@ -12,22 +12,22 @@ if (hasWASM()) {
|
|
|
12
12
|
wasm = inst.exports;
|
|
13
13
|
U8 = new Uint8Array(wasm.memory.buffer, wasm.buf, 16);
|
|
14
14
|
}
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
|
|
15
|
+
const __ensureWASM = () => !wasm && unsupported("WASM module unavailable");
|
|
16
|
+
const __encode = (op, signed) => (x) => {
|
|
17
|
+
__ensureWASM();
|
|
18
18
|
const value = signed ? BigInt.asIntN(64, BigInt(x)) : BigInt.asUintN(64, BigInt(x));
|
|
19
19
|
return U8.slice(0, wasm[op](value));
|
|
20
20
|
};
|
|
21
|
-
const
|
|
22
|
-
|
|
21
|
+
const __encodeInto = (op, signed) => (dst, x, pos = 0) => {
|
|
22
|
+
__ensureWASM();
|
|
23
23
|
const value = signed ? BigInt.asIntN(64, BigInt(x)) : BigInt.asUintN(64, BigInt(x));
|
|
24
24
|
const size = wasm[op](value);
|
|
25
25
|
ensureIndex(pos, 0, dst.length - size + 1);
|
|
26
26
|
dst.set(U8.subarray(0, size), pos);
|
|
27
27
|
return size;
|
|
28
28
|
};
|
|
29
|
-
const
|
|
30
|
-
|
|
29
|
+
const __decode = (op, signed) => (src, idx = 0) => {
|
|
30
|
+
__ensureWASM();
|
|
31
31
|
U8.set(src.subarray(idx, Math.min(idx + 10, src.length)), 0);
|
|
32
32
|
const value = wasm[op](0, 0);
|
|
33
33
|
return [
|
|
@@ -35,12 +35,12 @@ const decode = (op, signed) => (src, idx = 0) => {
|
|
|
35
35
|
U8[0]
|
|
36
36
|
];
|
|
37
37
|
};
|
|
38
|
-
const encodeSLEB128 =
|
|
39
|
-
const decodeSLEB128 =
|
|
40
|
-
const encodeSLEB128Into =
|
|
41
|
-
const encodeULEB128 =
|
|
42
|
-
const decodeULEB128 =
|
|
43
|
-
const encodeULEB128Into =
|
|
38
|
+
const encodeSLEB128 = __encode("leb128EncodeI64", true);
|
|
39
|
+
const decodeSLEB128 = __decode("leb128DecodeI64", true);
|
|
40
|
+
const encodeSLEB128Into = __encodeInto("leb128EncodeI64", true);
|
|
41
|
+
const encodeULEB128 = __encode("leb128EncodeU64", false);
|
|
42
|
+
const decodeULEB128 = __decode("leb128DecodeU64", false);
|
|
43
|
+
const encodeULEB128Into = __encodeInto("leb128EncodeU64", true);
|
|
44
44
|
export {
|
|
45
45
|
decodeSLEB128,
|
|
46
46
|
decodeULEB128,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/leb128",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.4",
|
|
4
4
|
"description": "WASM based LEB128 encoder / decoder (signed & unsigned)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"type": "git",
|
|
11
11
|
"url": "https://github.com/thi-ng/umbrella.git"
|
|
12
12
|
},
|
|
13
|
-
"homepage": "https://
|
|
13
|
+
"homepage": "https://thi.ng/binary",
|
|
14
14
|
"funding": [
|
|
15
15
|
{
|
|
16
16
|
"type": "github",
|
|
@@ -40,15 +40,15 @@
|
|
|
40
40
|
"tool:tangle": "../../node_modules/.bin/tangle src/**/*.ts"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@thi.ng/checks": "^3.6.
|
|
44
|
-
"@thi.ng/errors": "^2.5.
|
|
45
|
-
"@thi.ng/transducers-binary": "^2.1.
|
|
43
|
+
"@thi.ng/checks": "^3.6.5",
|
|
44
|
+
"@thi.ng/errors": "^2.5.8",
|
|
45
|
+
"@thi.ng/transducers-binary": "^2.1.121"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"@microsoft/api-extractor": "^7.
|
|
49
|
-
"esbuild": "^0.21.
|
|
48
|
+
"@microsoft/api-extractor": "^7.47.0",
|
|
49
|
+
"esbuild": "^0.21.5",
|
|
50
50
|
"typedoc": "^0.25.13",
|
|
51
|
-
"typescript": "^5.
|
|
51
|
+
"typescript": "^5.5.2"
|
|
52
52
|
},
|
|
53
53
|
"keywords": [
|
|
54
54
|
"64bit",
|
|
@@ -84,5 +84,5 @@
|
|
|
84
84
|
"alias": "leb",
|
|
85
85
|
"year": 2019
|
|
86
86
|
},
|
|
87
|
-
"gitHead": "
|
|
87
|
+
"gitHead": "154c95cf9d6bab32174498ec3b5b5d87e42be7f9\n"
|
|
88
88
|
}
|