@thi.ng/transducers-binary 2.1.120 → 2.1.121
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 +1 -1
- package/bits.d.ts +8 -3
- package/bytes.d.ts +5 -3
- package/hex-dump.d.ts +10 -6
- package/hex-dump.js +1 -1
- package/package.json +13 -13
- package/partition-bits.js +3 -3
- package/utf8.d.ts +6 -4
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
|
+
### [2.1.121](https://github.com/thi-ng/umbrella/tree/@thi.ng/transducers-binary@2.1.121) (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
|
### [2.1.115](https://github.com/thi-ng/umbrella/tree/@thi.ng/transducers-binary@2.1.115) (2024-04-08)
|
|
13
19
|
|
|
14
20
|
#### ♻️ Refactoring
|
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
|
>
|
package/bits.d.ts
CHANGED
|
@@ -4,13 +4,18 @@ import type { Transducer } from "@thi.ng/transducers";
|
|
|
4
4
|
* word size (default 8) and order (MSB first or LSB first). Only the
|
|
5
5
|
* lowest `wordSize` bits of each value are used (max 32).
|
|
6
6
|
*
|
|
7
|
-
* ```ts
|
|
7
|
+
* ```ts tangle:../export/bits.ts
|
|
8
8
|
* import { bits } from "@thi.ng/transducers-binary";
|
|
9
9
|
* import { comp, iterator, partition } from "@thi.ng/transducers";
|
|
10
10
|
*
|
|
11
|
-
*
|
|
11
|
+
* console.log(
|
|
12
|
+
* [...bits(8, [0xf0, 0xaa])]
|
|
13
|
+
* );
|
|
12
14
|
* // [ 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0 ]
|
|
13
|
-
*
|
|
15
|
+
*
|
|
16
|
+
* console.log(
|
|
17
|
+
* [...iterator(comp(bits(8), partition(4)), [0xf0, 0xaa])]
|
|
18
|
+
* );
|
|
14
19
|
* // [ [ 1, 1, 1, 1 ], [ 0, 0, 0, 0 ], [ 1, 0, 1, 0 ], [ 1, 0, 1, 0 ] ]
|
|
15
20
|
* ```
|
|
16
21
|
*
|
package/bytes.d.ts
CHANGED
|
@@ -27,18 +27,20 @@ export declare const str: (x: string) => BinStructItem;
|
|
|
27
27
|
* for streaming purposes).
|
|
28
28
|
*
|
|
29
29
|
* @example
|
|
30
|
-
* ```ts
|
|
30
|
+
* ```ts tangle:../export/as-bytes.ts
|
|
31
31
|
* import {
|
|
32
32
|
* asBytes, f32, i16, str, u32,
|
|
33
33
|
* hexDumpString
|
|
34
34
|
* } from "@thi.ng/transducers-binary";
|
|
35
35
|
*
|
|
36
|
-
*
|
|
36
|
+
* const bytes = asBytes([
|
|
37
37
|
* str("hello!"),
|
|
38
38
|
* u32(0xdecafbad),
|
|
39
39
|
* i16(-1),
|
|
40
40
|
* f32(Math.PI)
|
|
41
|
-
* ])
|
|
41
|
+
* ]);
|
|
42
|
+
*
|
|
43
|
+
* console.log(hexDumpString({}, bytes));
|
|
42
44
|
* // 00000000 | 68 65 6c 6c 6f 21 de ca fb ad ff ff 40 49 0f db | hello!......@I..
|
|
43
45
|
* ```
|
|
44
46
|
*/
|
package/hex-dump.d.ts
CHANGED
|
@@ -12,15 +12,19 @@ import type { HexDumpOpts } from "./api.js";
|
|
|
12
12
|
* [thi.ng/hex](https://docs.thi.ng/umbrella/hex/functions/hexdump.html)
|
|
13
13
|
*
|
|
14
14
|
* @example
|
|
15
|
-
* ```ts
|
|
15
|
+
* ```ts tangle:../export/hex-dump.ts
|
|
16
16
|
* import { hexDump } from "@thi.ng/transducers-binary";
|
|
17
17
|
*
|
|
18
|
-
* src = [
|
|
18
|
+
* const src = [
|
|
19
|
+
* 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 33, 48, 49, 50, 51, 126, 122, 121, 120
|
|
20
|
+
* ];
|
|
19
21
|
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
* //
|
|
22
|
+
* console.log(
|
|
23
|
+
* [...hexDump({ cols: 8, address: 0x400 }, src)].join("\n")
|
|
24
|
+
* );
|
|
25
|
+
* // 00000400 | 41 42 43 44 45 46 47 48 | ABCDEFGH
|
|
26
|
+
* // 00000408 | 49 4a 21 30 31 32 33 7e | IJ!0123~
|
|
27
|
+
* // 00000410 | 7a 79 78 00 00 00 00 00 | zyx.....
|
|
24
28
|
* ```
|
|
25
29
|
*
|
|
26
30
|
* @param opts -
|
package/hex-dump.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/transducers-binary",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.121",
|
|
4
4
|
"description": "Binary data related transducers & reducers",
|
|
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/transducers-binary",
|
|
14
14
|
"funding": [
|
|
15
15
|
{
|
|
16
16
|
"type": "github",
|
|
@@ -36,19 +36,19 @@
|
|
|
36
36
|
"tool:tangle": "../../node_modules/.bin/tangle src/**/*.ts"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@thi.ng/binary": "^3.4.
|
|
40
|
-
"@thi.ng/compose": "^3.0.
|
|
41
|
-
"@thi.ng/errors": "^2.5.
|
|
42
|
-
"@thi.ng/hex": "^2.3.
|
|
43
|
-
"@thi.ng/random": "^3.8.
|
|
44
|
-
"@thi.ng/strings": "^3.7.
|
|
45
|
-
"@thi.ng/transducers": "^9.0.
|
|
39
|
+
"@thi.ng/binary": "^3.4.26",
|
|
40
|
+
"@thi.ng/compose": "^3.0.5",
|
|
41
|
+
"@thi.ng/errors": "^2.5.8",
|
|
42
|
+
"@thi.ng/hex": "^2.3.47",
|
|
43
|
+
"@thi.ng/random": "^3.8.1",
|
|
44
|
+
"@thi.ng/strings": "^3.7.34",
|
|
45
|
+
"@thi.ng/transducers": "^9.0.6"
|
|
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
|
"array",
|
|
@@ -114,5 +114,5 @@
|
|
|
114
114
|
],
|
|
115
115
|
"year": 2018
|
|
116
116
|
},
|
|
117
|
-
"gitHead": "
|
|
117
|
+
"gitHead": "154c95cf9d6bab32174498ec3b5b5d87e42be7f9\n"
|
|
118
118
|
}
|
package/partition-bits.js
CHANGED
|
@@ -4,10 +4,10 @@ function partitionBits(...args) {
|
|
|
4
4
|
return __iter(partitionBits, args, iterator) || ((rfn) => {
|
|
5
5
|
const destSize = args[0];
|
|
6
6
|
const srcSize = args[1] || 8;
|
|
7
|
-
return destSize < srcSize ?
|
|
7
|
+
return destSize < srcSize ? __small(rfn, destSize, srcSize) : destSize > srcSize ? __large(rfn, destSize, srcSize) : rfn;
|
|
8
8
|
});
|
|
9
9
|
}
|
|
10
|
-
const
|
|
10
|
+
const __small = ([init, complete, reduce], n, wordSize) => {
|
|
11
11
|
const maxb = wordSize - n;
|
|
12
12
|
const m1 = (1 << wordSize) - 1;
|
|
13
13
|
const m2 = (1 << n) - 1;
|
|
@@ -31,7 +31,7 @@ const small = ([init, complete, reduce], n, wordSize) => {
|
|
|
31
31
|
}
|
|
32
32
|
];
|
|
33
33
|
};
|
|
34
|
-
const
|
|
34
|
+
const __large = ([init, complete, reduce], n, wordSize) => {
|
|
35
35
|
const m1 = (1 << wordSize) - 1;
|
|
36
36
|
let r = 0;
|
|
37
37
|
let y = 0;
|
package/utf8.d.ts
CHANGED
|
@@ -11,15 +11,17 @@ export declare function utf8Decode(src: Iterable<number>): string;
|
|
|
11
11
|
* Also see {@link utf8Decode} for reverse transformation.
|
|
12
12
|
*
|
|
13
13
|
* @example
|
|
14
|
-
* ```ts
|
|
14
|
+
* ```ts tangle:../export/utf8-encode.ts
|
|
15
15
|
* import { hexDump, utf8Encode } from "@thi.ng/transducers-binary";
|
|
16
16
|
* import { comp, str, transduce } from "@thi.ng/transducers";
|
|
17
17
|
*
|
|
18
|
-
* transduce(
|
|
19
|
-
* comp(utf8Encode(), hexDump()),
|
|
18
|
+
* const res = transduce(
|
|
19
|
+
* comp(utf8Encode(), hexDump({ cols: 8 })),
|
|
20
20
|
* str("\n"),
|
|
21
21
|
* "¡Hola niña! 😀"
|
|
22
|
-
* )
|
|
22
|
+
* );
|
|
23
|
+
*
|
|
24
|
+
* console.log(res);
|
|
23
25
|
* // 00000000 | c2 a1 48 6f 6c 61 20 6e | ..Hola n
|
|
24
26
|
* // 00000008 | 69 c3 b1 61 21 20 f0 9f | i..a! ..
|
|
25
27
|
* // 00000010 | 98 80 00 00 00 00 00 00 | ........
|