@thi.ng/transducers-binary 1.0.4 → 2.0.3
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 +50 -79
- package/README.md +20 -10
- package/base64.d.ts +2 -2
- package/base64.js +7 -5
- package/bits.d.ts +1 -1
- package/bits.js +4 -2
- package/bytes.d.ts +3 -3
- package/bytes.js +7 -5
- package/hex-dump.d.ts +2 -2
- package/hex-dump.js +9 -4
- package/index.d.ts +8 -8
- package/index.js +8 -8
- package/package.json +56 -27
- package/partition-bits.d.ts +1 -1
- package/partition-bits.js +3 -2
- package/random-bits.d.ts +1 -1
- package/random-bits.js +2 -2
- package/utf8.d.ts +2 -2
- package/utf8.js +4 -2
- package/lib/index.js +0 -618
- package/lib/index.js.map +0 -1
- package/lib/index.umd.js +0 -1
- package/lib/index.umd.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
-
## [
|
|
6
|
+
## [2.0.3](https://github.com/thi-ng/umbrella/compare/@thi.ng/transducers-binary@2.0.2...@thi.ng/transducers-binary@2.0.3) (2021-10-15)
|
|
7
7
|
|
|
8
8
|
**Note:** Version bump only for package @thi.ng/transducers-binary
|
|
9
9
|
|
|
@@ -11,7 +11,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
|
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
## [
|
|
14
|
+
## [2.0.2](https://github.com/thi-ng/umbrella/compare/@thi.ng/transducers-binary@2.0.1...@thi.ng/transducers-binary@2.0.2) (2021-10-15)
|
|
15
15
|
|
|
16
16
|
**Note:** Version bump only for package @thi.ng/transducers-binary
|
|
17
17
|
|
|
@@ -19,7 +19,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
|
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
|
|
22
|
-
## [
|
|
22
|
+
## [2.0.1](https://github.com/thi-ng/umbrella/compare/@thi.ng/transducers-binary@2.0.0...@thi.ng/transducers-binary@2.0.1) (2021-10-13)
|
|
23
23
|
|
|
24
24
|
**Note:** Version bump only for package @thi.ng/transducers-binary
|
|
25
25
|
|
|
@@ -27,122 +27,93 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
|
|
|
27
27
|
|
|
28
28
|
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
**Note:** Version bump only for package @thi.ng/transducers-binary
|
|
33
|
-
|
|
34
|
-
|
|
30
|
+
# [2.0.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/transducers-binary@1.0.5...@thi.ng/transducers-binary@2.0.0) (2021-10-12)
|
|
35
31
|
|
|
36
32
|
|
|
33
|
+
### Build System
|
|
37
34
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
**Note:** Version bump only for package @thi.ng/transducers-binary
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
## [0.6.24](https://github.com/thi-ng/umbrella/compare/@thi.ng/transducers-binary@0.6.23...@thi.ng/transducers-binary@0.6.24) (2021-08-04)
|
|
47
|
-
|
|
48
|
-
**Note:** Version bump only for package @thi.ng/transducers-binary
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
## [0.6.23](https://github.com/thi-ng/umbrella/compare/@thi.ng/transducers-binary@0.6.22...@thi.ng/transducers-binary@0.6.23) (2021-08-04)
|
|
55
|
-
|
|
56
|
-
**Note:** Version bump only for package @thi.ng/transducers-binary
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
## [0.6.22](https://github.com/thi-ng/umbrella/compare/@thi.ng/transducers-binary@0.6.21...@thi.ng/transducers-binary@0.6.22) (2021-07-27)
|
|
63
|
-
|
|
64
|
-
**Note:** Version bump only for package @thi.ng/transducers-binary
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
## [0.6.21](https://github.com/thi-ng/umbrella/compare/@thi.ng/transducers-binary@0.6.20...@thi.ng/transducers-binary@0.6.21) (2021-07-01)
|
|
71
|
-
|
|
72
|
-
**Note:** Version bump only for package @thi.ng/transducers-binary
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
## [0.6.20](https://github.com/thi-ng/umbrella/compare/@thi.ng/transducers-binary@0.6.19...@thi.ng/transducers-binary@0.6.20) (2021-06-08)
|
|
79
|
-
|
|
80
|
-
**Note:** Version bump only for package @thi.ng/transducers-binary
|
|
35
|
+
* major update of ALL pkgs (export maps, ESM only) ([0d1d6ea](https://github.com/thi-ng/umbrella/commit/0d1d6ea9fab2a645d6c5f2bf2591459b939c09b6))
|
|
81
36
|
|
|
82
37
|
|
|
38
|
+
### Features
|
|
83
39
|
|
|
40
|
+
* **transducers-binary:** update return types ([70217e8](https://github.com/thi-ng/umbrella/commit/70217e838d45f5cc3121d9c81d5e3a907eee9090))
|
|
84
41
|
|
|
85
42
|
|
|
86
|
-
|
|
43
|
+
### BREAKING CHANGES
|
|
87
44
|
|
|
45
|
+
* discontinue CommonJS & UMD versions
|
|
88
46
|
|
|
89
|
-
|
|
47
|
+
- only ESM modules will be published from now on
|
|
48
|
+
- CJS obsolete due to ESM support in recent versions of node:
|
|
49
|
+
- i.e. launch NodeJS via:
|
|
50
|
+
- `node --experimental-specifier-resolution=node --experimental-repl-await`
|
|
51
|
+
- in the node REPL use `await import(...)` instead of `require()`
|
|
52
|
+
- UMD obsolete due to widespread browser support for ESM
|
|
90
53
|
|
|
91
|
-
|
|
54
|
+
Also:
|
|
55
|
+
- normalize/restructure/reorg all package.json files
|
|
56
|
+
- cleanup all build scripts, remove obsolete
|
|
57
|
+
- switch from mocha to @thi.ng/testament for all tests
|
|
92
58
|
|
|
93
59
|
|
|
94
|
-
### BREAKING CHANGES
|
|
95
60
|
|
|
96
|
-
* **transducers-binary:** replace Type enum w/ type alias, update BinStructItem
|
|
97
61
|
|
|
98
62
|
|
|
99
63
|
|
|
64
|
+
## [1.0.5](https://github.com/thi-ng/umbrella/compare/@thi.ng/transducers-binary@1.0.4...@thi.ng/transducers-binary@1.0.5) (2021-09-03)
|
|
100
65
|
|
|
66
|
+
**Note:** Version bump only for package @thi.ng/transducers-binary
|
|
101
67
|
|
|
102
|
-
#
|
|
68
|
+
# [0.6.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/transducers-binary@0.5.33...@thi.ng/transducers-binary@0.6.0) (2020-12-22)
|
|
103
69
|
|
|
70
|
+
### Code Refactoring
|
|
104
71
|
|
|
105
|
-
|
|
72
|
+
- **transducers-binary:** fix [#256](https://github.com/thi-ng/umbrella/issues/256) replace enum w/ type alias ([50cc52a](https://github.com/thi-ng/umbrella/commit/50cc52a84b135535053370e022309aee5b670625))
|
|
106
73
|
|
|
107
|
-
|
|
108
|
-
* **transducers-binary:** add hexDumpString() syntax sugar ([a3ad805](https://github.com/thi-ng/umbrella/commit/a3ad805aefa4dd3836d7fb00cfbf0cf147b9d059))
|
|
109
|
-
* **transducers-binary:** add missing type impls to asBytes() ([6514292](https://github.com/thi-ng/umbrella/commit/65142927f520d0a90ca4f4bd5b7d570527e72923))
|
|
110
|
-
* **transducers-binary:** update bytes(), add i24/u24 support ([6d658d0](https://github.com/thi-ng/umbrella/commit/6d658d072977009f1289ba2cf230970dabf55d7f))
|
|
74
|
+
### BREAKING CHANGES
|
|
111
75
|
|
|
76
|
+
- **transducers-binary:** replace Type enum w/ type alias, update BinStructItem
|
|
112
77
|
|
|
78
|
+
# [0.5.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/transducers-binary@0.4.9...@thi.ng/transducers-binary@0.5.0) (2020-02-25)
|
|
113
79
|
|
|
80
|
+
### Features
|
|
114
81
|
|
|
82
|
+
- **transducers-binary:** add asBytes() transducer ([b8589d4](https://github.com/thi-ng/umbrella/commit/b8589d4cd0971adea9538fa9066870b4e32ded5b))
|
|
83
|
+
- **transducers-binary:** add hexDumpString() syntax sugar ([a3ad805](https://github.com/thi-ng/umbrella/commit/a3ad805aefa4dd3836d7fb00cfbf0cf147b9d059))
|
|
84
|
+
- **transducers-binary:** add missing type impls to asBytes() ([6514292](https://github.com/thi-ng/umbrella/commit/65142927f520d0a90ca4f4bd5b7d570527e72923))
|
|
85
|
+
- **transducers-binary:** update bytes(), add i24/u24 support ([6d658d0](https://github.com/thi-ng/umbrella/commit/6d658d072977009f1289ba2cf230970dabf55d7f))
|
|
115
86
|
|
|
116
|
-
#
|
|
87
|
+
# [0.4.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/transducers-binary@0.3.12...@thi.ng/transducers-binary@0.4.0) (2019-07-07)
|
|
117
88
|
|
|
118
|
-
###
|
|
89
|
+
### Features
|
|
119
90
|
|
|
120
|
-
|
|
91
|
+
- **transducers-binary:** enable TS strict compiler flags (refactor) ([8d86ac6](https://github.com/thi-ng/umbrella/commit/8d86ac6))
|
|
121
92
|
|
|
122
|
-
##
|
|
93
|
+
## [0.3.1](https://github.com/thi-ng/umbrella/compare/@thi.ng/transducers-binary@0.3.0...@thi.ng/transducers-binary@0.3.1) (2019-03-05)
|
|
123
94
|
|
|
124
|
-
###
|
|
95
|
+
### Bug Fixes
|
|
125
96
|
|
|
126
|
-
|
|
97
|
+
- **transducers-binary:** add randomBits() return type ([d79481f](https://github.com/thi-ng/umbrella/commit/d79481f))
|
|
127
98
|
|
|
128
|
-
#
|
|
99
|
+
# [0.3.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/transducers-binary@0.2.3...@thi.ng/transducers-binary@0.3.0) (2019-03-04)
|
|
129
100
|
|
|
130
|
-
###
|
|
101
|
+
### Features
|
|
131
102
|
|
|
132
|
-
|
|
103
|
+
- **transducers-binary:** add randomBits(), update readme ([36ca046](https://github.com/thi-ng/umbrella/commit/36ca046))
|
|
133
104
|
|
|
134
|
-
#
|
|
105
|
+
# [0.2.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/transducers-binary@0.1.1...@thi.ng/transducers-binary@0.2.0) (2019-02-15)
|
|
135
106
|
|
|
136
|
-
###
|
|
107
|
+
### Bug Fixes
|
|
137
108
|
|
|
138
|
-
|
|
109
|
+
- **transducers-binary:** update juxt import ([77ed4c5](https://github.com/thi-ng/umbrella/commit/77ed4c5))
|
|
139
110
|
|
|
140
|
-
###
|
|
111
|
+
### Features
|
|
141
112
|
|
|
142
|
-
|
|
113
|
+
- **transducers-binary:** add utf8Length() ([7cf98ef](https://github.com/thi-ng/umbrella/commit/7cf98ef))
|
|
143
114
|
|
|
144
|
-
#
|
|
115
|
+
# 0.1.0 (2019-02-05)
|
|
145
116
|
|
|
146
|
-
###
|
|
117
|
+
### Features
|
|
147
118
|
|
|
148
|
-
|
|
119
|
+
- **transducers-binary:** extract as new pkg from [@thi](https://github.com/thi).ng/transducers ([02877c7](https://github.com/thi-ng/umbrella/commit/02877c7))
|
package/README.md
CHANGED
|
@@ -53,15 +53,24 @@ iterable for direct use.
|
|
|
53
53
|
yarn add @thi.ng/transducers-binary
|
|
54
54
|
```
|
|
55
55
|
|
|
56
|
+
ES module import:
|
|
57
|
+
|
|
56
58
|
```html
|
|
57
|
-
|
|
58
|
-
|
|
59
|
+
<script type="module" src="https://cdn.skypack.dev/@thi.ng/transducers-binary"></script>
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
[Skypack documentation](https://docs.skypack.dev/)
|
|
63
|
+
|
|
64
|
+
For Node.js REPL:
|
|
65
|
+
|
|
66
|
+
```text
|
|
67
|
+
# with flag only for < v16
|
|
68
|
+
node --experimental-repl-await
|
|
59
69
|
|
|
60
|
-
|
|
61
|
-
<script src="https://unpkg.com/@thi.ng/transducers-binary/lib/index.umd.js" crossorigin></script>
|
|
70
|
+
> const transducersBinary = await import("@thi.ng/transducers-binary");
|
|
62
71
|
```
|
|
63
72
|
|
|
64
|
-
Package sizes (gzipped, pre-treeshake): ESM: 2.
|
|
73
|
+
Package sizes (gzipped, pre-treeshake): ESM: 2.70 KB
|
|
65
74
|
|
|
66
75
|
## Dependencies
|
|
67
76
|
|
|
@@ -80,11 +89,12 @@ directory are using this package.
|
|
|
80
89
|
|
|
81
90
|
A selection:
|
|
82
91
|
|
|
83
|
-
| Screenshot
|
|
84
|
-
|
|
85
|
-
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/bitmap-font.gif" width="240"/>
|
|
86
|
-
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/
|
|
87
|
-
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/
|
|
92
|
+
| Screenshot | Description | Live demo | Source |
|
|
93
|
+
|:-------------------------------------------------------------------------------------------------------------------------|:------------------------------------------------------|:--------------------------------------------------------|:-------------------------------------------------------------------------------------|
|
|
94
|
+
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/bitmap-font.gif" width="240"/> | Figlet-style bitmap font creation with transducers | [Demo](https://demo.thi.ng/umbrella/bitmap-font/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/bitmap-font) |
|
|
95
|
+
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/cellular-automata.png" width="240"/> | 2D transducer based cellular automata | [Demo](https://demo.thi.ng/umbrella/cellular-automata/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/cellular-automata) |
|
|
96
|
+
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/parse-playground.png" width="240"/> | Parser grammar livecoding editor/playground & codegen | [Demo](https://demo.thi.ng/umbrella/parse-playground/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/parse-playground) |
|
|
97
|
+
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/wolfram.png" width="240"/> | 1D Wolfram automata with OBJ point cloud export | [Demo](https://demo.thi.ng/umbrella/wolfram/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/wolfram) |
|
|
88
98
|
|
|
89
99
|
## API
|
|
90
100
|
|
package/base64.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { Transducer } from "@thi.ng/transducers";
|
|
1
|
+
import type { Transducer } from "@thi.ng/transducers";
|
|
2
2
|
/**
|
|
3
3
|
* Stateful transducer. Decodes base64 chars into bytes.
|
|
4
4
|
* Supports URL safe & unsafe flavors.
|
|
5
5
|
*/
|
|
6
6
|
export declare function base64Decode(): Transducer<string, number>;
|
|
7
|
-
export declare function base64Decode(src: string):
|
|
7
|
+
export declare function base64Decode(src: string): Uint8Array;
|
|
8
8
|
export interface Base64EncodeOpts {
|
|
9
9
|
safe: boolean;
|
|
10
10
|
buffer: number;
|
package/base64.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { compR } from "@thi.ng/transducers/compr";
|
|
2
|
+
import { iterator, iterator1, __iter } from "@thi.ng/transducers/iterator";
|
|
3
|
+
import { isReduced, reduced } from "@thi.ng/transducers/reduced";
|
|
2
4
|
const B64_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
3
5
|
const B64_SAFE = B64_CHARS.substr(0, 62) + "-_";
|
|
4
6
|
export function base64Decode(src) {
|
|
5
7
|
return src
|
|
6
|
-
? iterator1(base64Decode(), src)
|
|
8
|
+
? new Uint8Array([...iterator1(base64Decode(), src)])
|
|
7
9
|
: (rfn) => {
|
|
8
10
|
const r = rfn[2];
|
|
9
11
|
let bc = 0, bs = 0;
|
|
@@ -19,7 +21,7 @@ export function base64Decode(src) {
|
|
|
19
21
|
return reduced(acc);
|
|
20
22
|
default:
|
|
21
23
|
}
|
|
22
|
-
|
|
24
|
+
const y = B64_CHARS.indexOf(x);
|
|
23
25
|
bs = bc & 3 ? (bs << 6) + y : y;
|
|
24
26
|
if (bc++ & 3) {
|
|
25
27
|
acc = r(acc, 255 & (bs >> ((-2 * bc) & 6)));
|
|
@@ -29,14 +31,14 @@ export function base64Decode(src) {
|
|
|
29
31
|
};
|
|
30
32
|
}
|
|
31
33
|
export function base64Encode(...args) {
|
|
32
|
-
const iter =
|
|
34
|
+
const iter = __iter(base64Encode, args, iterator);
|
|
33
35
|
if (iter) {
|
|
34
36
|
return [...iter].join("");
|
|
35
37
|
}
|
|
36
38
|
return ([init, complete, reduce]) => {
|
|
37
39
|
let state = 0;
|
|
38
40
|
let b;
|
|
39
|
-
const opts =
|
|
41
|
+
const opts = { safe: false, buffer: 1024, ...args[0] };
|
|
40
42
|
const chars = opts.safe ? B64_SAFE : B64_CHARS;
|
|
41
43
|
const buf = [];
|
|
42
44
|
return [
|
package/bits.d.ts
CHANGED
package/bits.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { compR } from "@thi.ng/transducers/compr";
|
|
2
|
+
import { iterator, __iter } from "@thi.ng/transducers/iterator";
|
|
3
|
+
import { isReduced } from "@thi.ng/transducers/reduced";
|
|
2
4
|
export function bits(...args) {
|
|
3
|
-
return (
|
|
5
|
+
return (__iter(bits, args, iterator) ||
|
|
4
6
|
((rfn) => {
|
|
5
7
|
const reduce = rfn[2];
|
|
6
8
|
const size = args[0] || 8;
|
package/bytes.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Reducer, Transducer } from "@thi.ng/transducers";
|
|
2
|
-
import type { BinStructItem } from "./api";
|
|
1
|
+
import type { Reducer, Transducer } from "@thi.ng/transducers";
|
|
2
|
+
import type { BinStructItem } from "./api.js";
|
|
3
3
|
export declare const i8: (x: number) => BinStructItem;
|
|
4
4
|
export declare const i8array: (x: ArrayLike<number>) => BinStructItem;
|
|
5
5
|
export declare const u8: (x: number) => BinStructItem;
|
|
@@ -38,7 +38,7 @@ export declare const str: (x: string) => BinStructItem;
|
|
|
38
38
|
* ```
|
|
39
39
|
*/
|
|
40
40
|
export declare function asBytes(): Transducer<BinStructItem, number>;
|
|
41
|
-
export declare function asBytes(src: Iterable<BinStructItem>):
|
|
41
|
+
export declare function asBytes(src: Iterable<BinStructItem>): Iterable<number>;
|
|
42
42
|
export declare function bytes(cap?: number): Reducer<Uint8Array, BinStructItem>;
|
|
43
43
|
export declare function bytes(cap: number, src: Iterable<BinStructItem>): Uint8Array;
|
|
44
44
|
//# sourceMappingURL=bytes.d.ts.map
|
package/bytes.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { bytes16, bytes24, bytes32, bytesF32, bytesF64 } from "@thi.ng/binary";
|
|
2
|
-
import { unsupported } from "@thi.ng/errors";
|
|
3
|
-
import { iterator
|
|
4
|
-
import {
|
|
1
|
+
import { bytes16, bytes24, bytes32, bytesF32, bytesF64, } from "@thi.ng/binary/bytes";
|
|
2
|
+
import { unsupported } from "@thi.ng/errors/unsupported";
|
|
3
|
+
import { iterator } from "@thi.ng/transducers/iterator";
|
|
4
|
+
import { mapcat } from "@thi.ng/transducers/mapcat";
|
|
5
|
+
import { reduce } from "@thi.ng/transducers/reduce";
|
|
6
|
+
import { utf8Encode } from "./utf8.js";
|
|
5
7
|
export const i8 = (x) => ["i8", x];
|
|
6
8
|
export const i8array = (x) => ["i8a", x];
|
|
7
9
|
export const u8 = (x) => ["u8", x];
|
|
@@ -221,7 +223,7 @@ export function bytes(cap = 1024, src) {
|
|
|
221
223
|
acc = setArray("setFloat64", 8, acc, x, le);
|
|
222
224
|
break;
|
|
223
225
|
case "str": {
|
|
224
|
-
let utf =
|
|
226
|
+
let utf = utf8Encode(x);
|
|
225
227
|
acc = ensure(acc, utf.length);
|
|
226
228
|
acc.set(utf, pos);
|
|
227
229
|
pos += utf.length;
|
package/hex-dump.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Transducer } from "@thi.ng/transducers";
|
|
2
|
-
import type { HexDumpOpts } from "./api";
|
|
1
|
+
import type { Transducer } from "@thi.ng/transducers";
|
|
2
|
+
import type { HexDumpOpts } from "./api.js";
|
|
3
3
|
/**
|
|
4
4
|
* Transforms bytes into a sequence of hexdump lines with configurable
|
|
5
5
|
* number of `columns` and `address` offset. Uses
|
package/hex-dump.js
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
|
-
import { juxt } from "@thi.ng/compose";
|
|
1
|
+
import { juxt } from "@thi.ng/compose/juxt";
|
|
2
2
|
import { U32, U8 } from "@thi.ng/hex";
|
|
3
|
-
import {
|
|
3
|
+
import { comp } from "@thi.ng/transducers/comp";
|
|
4
|
+
import { iterator, __iter } from "@thi.ng/transducers/iterator";
|
|
5
|
+
import { map } from "@thi.ng/transducers/map";
|
|
6
|
+
import { mapIndexed } from "@thi.ng/transducers/map-indexed";
|
|
7
|
+
import { padLast } from "@thi.ng/transducers/pad-last";
|
|
8
|
+
import { partition } from "@thi.ng/transducers/partition";
|
|
4
9
|
export function hexDump(...args) {
|
|
5
|
-
const iter =
|
|
10
|
+
const iter = __iter(hexDump, args, iterator);
|
|
6
11
|
if (iter) {
|
|
7
12
|
return iter;
|
|
8
13
|
}
|
|
9
|
-
const { cols, address } =
|
|
14
|
+
const { cols, address } = { cols: 16, address: 0, ...args[0] };
|
|
10
15
|
return comp(padLast(cols, 0), map(juxt(U8, (x) => (x > 31 && x < 127 ? String.fromCharCode(x) : "."))), partition(cols, true), map(juxt((x) => x.map((y) => y[0]).join(" "), (x) => x.map((y) => y[1]).join(""))), mapIndexed((i, [h, a]) => `${U32(address + i * cols)} | ${h} | ${a}`));
|
|
11
16
|
}
|
|
12
17
|
/**
|
package/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export * from "./api";
|
|
2
|
-
export * from "./base64";
|
|
3
|
-
export * from "./bytes";
|
|
4
|
-
export * from "./bits";
|
|
5
|
-
export * from "./hex-dump";
|
|
6
|
-
export * from "./partition-bits";
|
|
7
|
-
export * from "./random-bits";
|
|
8
|
-
export * from "./utf8";
|
|
1
|
+
export * from "./api.js";
|
|
2
|
+
export * from "./base64.js";
|
|
3
|
+
export * from "./bytes.js";
|
|
4
|
+
export * from "./bits.js";
|
|
5
|
+
export * from "./hex-dump.js";
|
|
6
|
+
export * from "./partition-bits.js";
|
|
7
|
+
export * from "./random-bits.js";
|
|
8
|
+
export * from "./utf8.js";
|
|
9
9
|
//# sourceMappingURL=index.d.ts.map
|
package/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export * from "./api";
|
|
2
|
-
export * from "./base64";
|
|
3
|
-
export * from "./bytes";
|
|
4
|
-
export * from "./bits";
|
|
5
|
-
export * from "./hex-dump";
|
|
6
|
-
export * from "./partition-bits";
|
|
7
|
-
export * from "./random-bits";
|
|
8
|
-
export * from "./utf8";
|
|
1
|
+
export * from "./api.js";
|
|
2
|
+
export * from "./base64.js";
|
|
3
|
+
export * from "./bytes.js";
|
|
4
|
+
export * from "./bits.js";
|
|
5
|
+
export * from "./hex-dump.js";
|
|
6
|
+
export * from "./partition-bits.js";
|
|
7
|
+
export * from "./random-bits.js";
|
|
8
|
+
export * from "./utf8.js";
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/transducers-binary",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.3",
|
|
4
4
|
"description": "Binary data related transducers & reducers",
|
|
5
|
+
"type": "module",
|
|
5
6
|
"module": "./index.js",
|
|
6
|
-
"main": "./lib/index.js",
|
|
7
|
-
"umd:main": "./lib/index.umd.js",
|
|
8
7
|
"typings": "./index.d.ts",
|
|
8
|
+
"sideEffects": false,
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
11
11
|
"url": "https://github.com/thi-ng/umbrella.git"
|
|
@@ -24,32 +24,26 @@
|
|
|
24
24
|
"author": "Karsten Schmidt <k+npm@thi.ng>",
|
|
25
25
|
"license": "Apache-2.0",
|
|
26
26
|
"scripts": {
|
|
27
|
-
"build": "yarn clean &&
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"build:test": "rimraf build && tsc -p test/tsconfig.json",
|
|
31
|
-
"build:check": "tsc --isolatedModules --noEmit",
|
|
32
|
-
"test": "mocha test",
|
|
33
|
-
"cover": "nyc mocha test && nyc report --reporter=lcov",
|
|
34
|
-
"clean": "rimraf *.js *.d.ts *.map .nyc_output build coverage doc lib",
|
|
35
|
-
"doc:readme": "ts-node -P ../../tools/tsconfig.json ../../tools/src/readme.ts",
|
|
36
|
-
"doc": "typedoc --excludePrivate --out doc --theme ../../tools/doc/typedoc-theme src/index.ts",
|
|
27
|
+
"build": "yarn clean && tsc --declaration",
|
|
28
|
+
"clean": "rimraf *.js *.d.ts *.map doc",
|
|
29
|
+
"doc": "typedoc --excludePrivate --excludeInternal --out doc src/index.ts",
|
|
37
30
|
"doc:ae": "mkdir -p .ae/doc .ae/temp && node_modules/.bin/api-extractor run --local --verbose",
|
|
38
|
-
"
|
|
31
|
+
"doc:readme": "yarn doc:stats && ../../scripts/node-esm ../../tools/src/readme.ts",
|
|
32
|
+
"doc:stats": "../../scripts/node-esm ../../tools/src/module-stats.ts",
|
|
33
|
+
"pub": "yarn build && yarn publish --access public",
|
|
34
|
+
"test": "testament test"
|
|
39
35
|
},
|
|
40
36
|
"dependencies": {
|
|
41
|
-
"@thi.ng/binary": "^
|
|
42
|
-
"@thi.ng/compose": "^
|
|
43
|
-
"@thi.ng/errors": "^
|
|
44
|
-
"@thi.ng/hex": "^
|
|
45
|
-
"@thi.ng/random": "^
|
|
46
|
-
"@thi.ng/transducers": "^
|
|
37
|
+
"@thi.ng/binary": "^3.0.3",
|
|
38
|
+
"@thi.ng/compose": "^2.0.3",
|
|
39
|
+
"@thi.ng/errors": "^2.0.3",
|
|
40
|
+
"@thi.ng/hex": "^2.0.3",
|
|
41
|
+
"@thi.ng/random": "^3.0.3",
|
|
42
|
+
"@thi.ng/transducers": "^8.0.3"
|
|
43
|
+
},
|
|
44
|
+
"devDependencies": {
|
|
45
|
+
"@thi.ng/testament": "^0.1.3"
|
|
47
46
|
},
|
|
48
|
-
"files": [
|
|
49
|
-
"*.js",
|
|
50
|
-
"*.d.ts",
|
|
51
|
-
"lib"
|
|
52
|
-
],
|
|
53
47
|
"keywords": [
|
|
54
48
|
"array",
|
|
55
49
|
"base64",
|
|
@@ -68,7 +62,42 @@
|
|
|
68
62
|
"publishConfig": {
|
|
69
63
|
"access": "public"
|
|
70
64
|
},
|
|
71
|
-
"
|
|
65
|
+
"engines": {
|
|
66
|
+
"node": ">=12.7"
|
|
67
|
+
},
|
|
68
|
+
"files": [
|
|
69
|
+
"*.js",
|
|
70
|
+
"*.d.ts"
|
|
71
|
+
],
|
|
72
|
+
"exports": {
|
|
73
|
+
".": {
|
|
74
|
+
"import": "./index.js"
|
|
75
|
+
},
|
|
76
|
+
"./api": {
|
|
77
|
+
"import": "./api.js"
|
|
78
|
+
},
|
|
79
|
+
"./base64": {
|
|
80
|
+
"import": "./base64.js"
|
|
81
|
+
},
|
|
82
|
+
"./bits": {
|
|
83
|
+
"import": "./bits.js"
|
|
84
|
+
},
|
|
85
|
+
"./bytes": {
|
|
86
|
+
"import": "./bytes.js"
|
|
87
|
+
},
|
|
88
|
+
"./hex-dump": {
|
|
89
|
+
"import": "./hex-dump.js"
|
|
90
|
+
},
|
|
91
|
+
"./partition-bits": {
|
|
92
|
+
"import": "./partition-bits.js"
|
|
93
|
+
},
|
|
94
|
+
"./random-bits": {
|
|
95
|
+
"import": "./random-bits.js"
|
|
96
|
+
},
|
|
97
|
+
"./utf8": {
|
|
98
|
+
"import": "./utf8.js"
|
|
99
|
+
}
|
|
100
|
+
},
|
|
72
101
|
"thi.ng": {
|
|
73
102
|
"parent": "@thi.ng/transducers",
|
|
74
103
|
"related": [
|
|
@@ -78,5 +107,5 @@
|
|
|
78
107
|
],
|
|
79
108
|
"year": 2018
|
|
80
109
|
},
|
|
81
|
-
"gitHead": "
|
|
110
|
+
"gitHead": "1fb38cac74d6c009d96855c28784a267a81badf1"
|
|
82
111
|
}
|
package/partition-bits.d.ts
CHANGED
package/partition-bits.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { iterator, __iter } from "@thi.ng/transducers/iterator";
|
|
2
|
+
import { isReduced } from "@thi.ng/transducers/reduced";
|
|
2
3
|
export function partitionBits(...args) {
|
|
3
|
-
return (
|
|
4
|
+
return (__iter(partitionBits, args, iterator) ||
|
|
4
5
|
((rfn) => {
|
|
5
6
|
const destSize = args[0];
|
|
6
7
|
const srcSize = args[1] || 8;
|
package/random-bits.d.ts
CHANGED
package/random-bits.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { SYSTEM } from "@thi.ng/random";
|
|
2
|
-
import { repeatedly } from "@thi.ng/transducers";
|
|
1
|
+
import { SYSTEM } from "@thi.ng/random/system";
|
|
2
|
+
import { repeatedly } from "@thi.ng/transducers/repeatedly";
|
|
3
3
|
/**
|
|
4
4
|
* Returns an iterator of random bits, with 1's occurring w/ given
|
|
5
5
|
* probability `prob` (in the [0,1] interval). If `num` is given, only
|
package/utf8.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Transducer } from "@thi.ng/transducers";
|
|
1
|
+
import type { Transducer } from "@thi.ng/transducers";
|
|
2
2
|
/**
|
|
3
3
|
* Transducer which decodes a byte input sequence into UTF-8 characters.
|
|
4
4
|
* Also see {@link (utf8Encode:1)} for reverse transformation.
|
|
@@ -23,6 +23,6 @@ export declare function utf8Decode(src: Iterable<number>): string;
|
|
|
23
23
|
* ```
|
|
24
24
|
*/
|
|
25
25
|
export declare function utf8Encode(): Transducer<string, number>;
|
|
26
|
-
export declare function utf8Encode(src: string):
|
|
26
|
+
export declare function utf8Encode(src: string): Uint8Array;
|
|
27
27
|
export declare const utf8Length: (str: string) => number;
|
|
28
28
|
//# sourceMappingURL=utf8.d.ts.map
|
package/utf8.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import { compR
|
|
1
|
+
import { compR } from "@thi.ng/transducers/compr";
|
|
2
|
+
import { iterator, iterator1 } from "@thi.ng/transducers/iterator";
|
|
3
|
+
import { isReduced } from "@thi.ng/transducers/reduced";
|
|
2
4
|
export function utf8Decode(src) {
|
|
3
5
|
return src
|
|
4
6
|
? [...iterator1(utf8Decode(), src)].join("")
|
|
@@ -74,7 +76,7 @@ export function utf8Decode(src) {
|
|
|
74
76
|
}
|
|
75
77
|
export function utf8Encode(src) {
|
|
76
78
|
return src != null
|
|
77
|
-
? iterator(utf8Encode(), src)
|
|
79
|
+
? new Uint8Array([...iterator(utf8Encode(), src)])
|
|
78
80
|
: (rfn) => {
|
|
79
81
|
const r = rfn[2];
|
|
80
82
|
return compR(rfn, (acc, x) => {
|