@e280/stz 0.0.0-14 → 0.0.0-15
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/README.md +41 -7
- package/package.json +1 -1
- package/s/data/bytename/bytename.test.ts +12 -12
- package/s/data/bytename/bytename.ts +17 -9
- package/x/data/bytename/bytename.d.ts +8 -4
- package/x/data/bytename/bytename.js +14 -9
- package/x/data/bytename/bytename.js.map +1 -1
- package/x/data/bytename/bytename.test.js +12 -12
- package/x/data/bytename/bytename.test.js.map +1 -1
package/README.md
CHANGED
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
|
|
2
2
|
# `@e280/stz`
|
|
3
3
|
standard library of environment-agnostic typescript functions we use basically everywhere
|
|
4
|
-
|
|
5
4
|
- zero dependencies
|
|
6
5
|
|
|
7
6
|
<br/>
|
|
8
7
|
|
|
9
|
-
##
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
### MapG — an extension of js Map with handy methods
|
|
8
|
+
## MapG
|
|
9
|
+
### extended js map
|
|
13
10
|
- `map.require`
|
|
14
11
|
```ts
|
|
15
12
|
import {MapG} from "@e280/stz"
|
|
@@ -28,7 +25,10 @@ stz has many more tools than documented below, see their [sourcecode here in s/]
|
|
|
28
25
|
const value = map.guarantee(3, () => "rofl")
|
|
29
26
|
```
|
|
30
27
|
|
|
31
|
-
|
|
28
|
+
<br/>
|
|
29
|
+
|
|
30
|
+
## pub and sub
|
|
31
|
+
### ergonomic event emitters
|
|
32
32
|
- make a publisher fn
|
|
33
33
|
```ts
|
|
34
34
|
import {pub} from "@e280/stz"
|
|
@@ -81,7 +81,41 @@ stz has many more tools than documented below, see their [sourcecode here in s/]
|
|
|
81
81
|
|
|
82
82
|
<br/>
|
|
83
83
|
|
|
84
|
-
##
|
|
84
|
+
## Bytename
|
|
85
|
+
### friendly string encoding for binary data
|
|
86
|
+
|
|
87
|
+
a bytename looks like `"midsen.picmyn.widrep.baclut dotreg.filtyp.nosnus.siptev"`. that's 16 bytes. each byte maps to a three-letter triplet
|
|
88
|
+
|
|
89
|
+
the bytename parser (`Bytename.toBytes`) ignores all non-alphabetic characters. thus `midsen.picmyn`, `midsenpicmyn`, and `mid@sen$pic@myn` are all equal.
|
|
90
|
+
|
|
91
|
+
```ts
|
|
92
|
+
import {Bytename} from "@e280/stz"
|
|
93
|
+
```
|
|
94
|
+
- ```ts
|
|
95
|
+
Bytename.fromBytes(new Uint8Array([0xDE, 0xAD, 0xBE, 0xEF]))
|
|
96
|
+
// "ribmug.hilmun"
|
|
97
|
+
```
|
|
98
|
+
- ```ts
|
|
99
|
+
Bytename.toBytes("ribmug.hilmun")
|
|
100
|
+
// Uint8Array, 4 bytes
|
|
101
|
+
```
|
|
102
|
+
- ```ts
|
|
103
|
+
const bytes = new Uint8Array([
|
|
104
|
+
0xDE, 0xAD, 0xBE, 0xEF,
|
|
105
|
+
0xDE, 0xAD, 0xBE, 0xEF,
|
|
106
|
+
])
|
|
107
|
+
|
|
108
|
+
Bytename.fromBytes(bytes, {
|
|
109
|
+
groupSize: 2, // default is 4
|
|
110
|
+
groupSeparator: " ",
|
|
111
|
+
wordSeparator: ".",
|
|
112
|
+
})
|
|
113
|
+
// "ribmug.hilmun ribmug.hilmun"
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
<br/>
|
|
117
|
+
|
|
118
|
+
## 💖 stz is made with open source love
|
|
85
119
|
reward us with github stars
|
|
86
120
|
build with us at https://e280.org/ but only if you're cool
|
|
87
121
|
|
package/package.json
CHANGED
|
@@ -11,24 +11,24 @@ function good(bytes: Uint8Array) {
|
|
|
11
11
|
|
|
12
12
|
export default Science.suite({
|
|
13
13
|
"bytes->string->bytes": test(async() => {
|
|
14
|
-
const text = Bytename.
|
|
14
|
+
const text = Bytename.fromBytes(deadbeef)
|
|
15
15
|
expect(text).is("ribmug.hilmun")
|
|
16
|
-
good(Bytename.
|
|
16
|
+
good(Bytename.toBytes(text))
|
|
17
17
|
}),
|
|
18
18
|
|
|
19
19
|
"zero bytes": test(async() => {
|
|
20
|
-
const text = Bytename.
|
|
20
|
+
const text = Bytename.fromBytes(new Uint8Array([]))
|
|
21
21
|
expect(text).is("")
|
|
22
22
|
}),
|
|
23
23
|
|
|
24
24
|
"one byte": test(async() => {
|
|
25
|
-
const text = Bytename.
|
|
25
|
+
const text = Bytename.fromBytes(new Uint8Array([0x00]))
|
|
26
26
|
expect(text).is("doz")
|
|
27
27
|
}),
|
|
28
28
|
|
|
29
29
|
"groupings": test(async() => {
|
|
30
30
|
const bytes = new Uint8Array([...deadbeef, ...deadbeef])
|
|
31
|
-
const text = Bytename.
|
|
31
|
+
const text = Bytename.fromBytes(bytes, {
|
|
32
32
|
groupSize: 2,
|
|
33
33
|
groupSeparator: " ",
|
|
34
34
|
wordSeparator: ".",
|
|
@@ -37,13 +37,13 @@ export default Science.suite({
|
|
|
37
37
|
}),
|
|
38
38
|
|
|
39
39
|
"wordsep": Science.suite({
|
|
40
|
-
"underscore": test(async() => good(Bytename.
|
|
41
|
-
"uppercase": test(async() => good(Bytename.
|
|
42
|
-
"dots": test(async() => good(Bytename.
|
|
43
|
-
"crushed": test(async() => good(Bytename.
|
|
44
|
-
"space": test(async() => good(Bytename.
|
|
45
|
-
"spaces": test(async() => good(Bytename.
|
|
46
|
-
"whitespace": test(async() => good(Bytename.
|
|
40
|
+
"underscore": test(async() => good(Bytename.toBytes("ribmug_hilmun"))),
|
|
41
|
+
"uppercase": test(async() => good(Bytename.toBytes("RIBMUG_HILMUN"))),
|
|
42
|
+
"dots": test(async() => good(Bytename.toBytes("ribmug.hilmun"))),
|
|
43
|
+
"crushed": test(async() => good(Bytename.toBytes("ribmughilmun"))),
|
|
44
|
+
"space": test(async() => good(Bytename.toBytes("ribmug hilmun"))),
|
|
45
|
+
"spaces": test(async() => good(Bytename.toBytes("ribmug hilmun"))),
|
|
46
|
+
"whitespace": test(async() => good(Bytename.toBytes("\n ribmug \n \t \n hilmun \n"))),
|
|
47
47
|
}),
|
|
48
48
|
})
|
|
49
49
|
|
|
@@ -11,11 +11,9 @@ export type BytenameOptions = {
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
|
-
* Bytename is a
|
|
14
|
+
* Bytename is a friendly presentation format for arbitrary binary data.
|
|
15
15
|
* - looks like "midsen.picmyn.widrep.baclut dotreg.filtyp.nosnus.siptev"
|
|
16
16
|
* - each byte maps to a three-letter triplet
|
|
17
|
-
* - six-letter words are separated by a delimiter
|
|
18
|
-
* - four-word groups are separated by a delimiter
|
|
19
17
|
* - all delimiters are just sugar, parser doesn't care
|
|
20
18
|
*/
|
|
21
19
|
export const Bytename = {
|
|
@@ -26,10 +24,11 @@ export const Bytename = {
|
|
|
26
24
|
}),
|
|
27
25
|
|
|
28
26
|
random(byteCount: number, options?: Partial<BytenameOptions>) {
|
|
29
|
-
|
|
27
|
+
const bytes = Bytes.random(byteCount)
|
|
28
|
+
return this.fromBytes(bytes, options)
|
|
30
29
|
},
|
|
31
30
|
|
|
32
|
-
|
|
31
|
+
fromBytes(bytes: Uint8Array, options: Partial<BytenameOptions> = {}) {
|
|
33
32
|
const {
|
|
34
33
|
groupSize = Bytename.defaults.groupSize,
|
|
35
34
|
wordSeparator = Bytename.defaults.wordSeparator,
|
|
@@ -58,7 +57,7 @@ export const Bytename = {
|
|
|
58
57
|
return grouped.join(groupSeparator)
|
|
59
58
|
},
|
|
60
59
|
|
|
61
|
-
|
|
60
|
+
toBytes(bytename: string) {
|
|
62
61
|
const letters = bytename
|
|
63
62
|
.toLowerCase()
|
|
64
63
|
.replace(/[^a-z]/g, "") // strip everything except letters
|
|
@@ -80,12 +79,21 @@ export const Bytename = {
|
|
|
80
79
|
}))
|
|
81
80
|
},
|
|
82
81
|
|
|
83
|
-
|
|
84
|
-
return Hex.string(Bytename.
|
|
82
|
+
toHex(bytename: string) {
|
|
83
|
+
return Hex.string(Bytename.toBytes(bytename))
|
|
85
84
|
},
|
|
86
85
|
|
|
87
86
|
fromHex(hex: string, options?: Partial<BytenameOptions>) {
|
|
88
|
-
return Bytename.
|
|
87
|
+
return Bytename.fromBytes(Hex.bytes(hex), options)
|
|
89
88
|
},
|
|
89
|
+
|
|
90
|
+
/** @deprecated renamed to `fromBytes` */
|
|
91
|
+
string(bytes: Uint8Array, options: Partial<BytenameOptions> = {}) { return Bytename.fromBytes(bytes, options) },
|
|
92
|
+
|
|
93
|
+
/** @deprecated renamed to `toBytes` */
|
|
94
|
+
bytes(bytename: string) { return Bytename.toBytes(bytename) },
|
|
95
|
+
|
|
96
|
+
/** @deprecated renamed to `toHex` */
|
|
97
|
+
hex(bytename: string) { return Bytename.toHex(bytename) },
|
|
90
98
|
}
|
|
91
99
|
|
|
@@ -4,18 +4,22 @@ export type BytenameOptions = {
|
|
|
4
4
|
groupSeparator: string;
|
|
5
5
|
};
|
|
6
6
|
/**
|
|
7
|
-
* Bytename is a
|
|
7
|
+
* Bytename is a friendly presentation format for arbitrary binary data.
|
|
8
8
|
* - looks like "midsen.picmyn.widrep.baclut dotreg.filtyp.nosnus.siptev"
|
|
9
9
|
* - each byte maps to a three-letter triplet
|
|
10
|
-
* - six-letter words are separated by a delimiter
|
|
11
|
-
* - four-word groups are separated by a delimiter
|
|
12
10
|
* - all delimiters are just sugar, parser doesn't care
|
|
13
11
|
*/
|
|
14
12
|
export declare const Bytename: {
|
|
15
13
|
defaults: BytenameOptions;
|
|
16
14
|
random(byteCount: number, options?: Partial<BytenameOptions>): string;
|
|
15
|
+
fromBytes(bytes: Uint8Array, options?: Partial<BytenameOptions>): string;
|
|
16
|
+
toBytes(bytename: string): Uint8Array<ArrayBuffer>;
|
|
17
|
+
toHex(bytename: string): string;
|
|
18
|
+
fromHex(hex: string, options?: Partial<BytenameOptions>): string;
|
|
19
|
+
/** @deprecated renamed to `fromBytes` */
|
|
17
20
|
string(bytes: Uint8Array, options?: Partial<BytenameOptions>): string;
|
|
21
|
+
/** @deprecated renamed to `toBytes` */
|
|
18
22
|
bytes(bytename: string): Uint8Array<ArrayBuffer>;
|
|
23
|
+
/** @deprecated renamed to `toHex` */
|
|
19
24
|
hex(bytename: string): string;
|
|
20
|
-
fromHex(hex: string, options?: Partial<BytenameOptions>): string;
|
|
21
25
|
};
|
|
@@ -3,11 +3,9 @@ import { Bytes } from "../bytes.js";
|
|
|
3
3
|
import { prefixes } from "./utils/prefixes.js";
|
|
4
4
|
import { suffixes } from "./utils/suffixes.js";
|
|
5
5
|
/**
|
|
6
|
-
* Bytename is a
|
|
6
|
+
* Bytename is a friendly presentation format for arbitrary binary data.
|
|
7
7
|
* - looks like "midsen.picmyn.widrep.baclut dotreg.filtyp.nosnus.siptev"
|
|
8
8
|
* - each byte maps to a three-letter triplet
|
|
9
|
-
* - six-letter words are separated by a delimiter
|
|
10
|
-
* - four-word groups are separated by a delimiter
|
|
11
9
|
* - all delimiters are just sugar, parser doesn't care
|
|
12
10
|
*/
|
|
13
11
|
export const Bytename = {
|
|
@@ -17,9 +15,10 @@ export const Bytename = {
|
|
|
17
15
|
groupSeparator: " ",
|
|
18
16
|
},
|
|
19
17
|
random(byteCount, options) {
|
|
20
|
-
|
|
18
|
+
const bytes = Bytes.random(byteCount);
|
|
19
|
+
return this.fromBytes(bytes, options);
|
|
21
20
|
},
|
|
22
|
-
|
|
21
|
+
fromBytes(bytes, options = {}) {
|
|
23
22
|
const { groupSize = Bytename.defaults.groupSize, wordSeparator = Bytename.defaults.wordSeparator, groupSeparator = Bytename.defaults.groupSeparator, } = options;
|
|
24
23
|
const words = [];
|
|
25
24
|
let currentWord = [];
|
|
@@ -38,7 +37,7 @@ export const Bytename = {
|
|
|
38
37
|
grouped.push(words.slice(i, i + groupSize).join(wordSeparator));
|
|
39
38
|
return grouped.join(groupSeparator);
|
|
40
39
|
},
|
|
41
|
-
|
|
40
|
+
toBytes(bytename) {
|
|
42
41
|
const letters = bytename
|
|
43
42
|
.toLowerCase()
|
|
44
43
|
.replace(/[^a-z]/g, ""); // strip everything except letters
|
|
@@ -56,11 +55,17 @@ export const Bytename = {
|
|
|
56
55
|
return number;
|
|
57
56
|
}));
|
|
58
57
|
},
|
|
59
|
-
|
|
60
|
-
return Hex.string(Bytename.
|
|
58
|
+
toHex(bytename) {
|
|
59
|
+
return Hex.string(Bytename.toBytes(bytename));
|
|
61
60
|
},
|
|
62
61
|
fromHex(hex, options) {
|
|
63
|
-
return Bytename.
|
|
62
|
+
return Bytename.fromBytes(Hex.bytes(hex), options);
|
|
64
63
|
},
|
|
64
|
+
/** @deprecated renamed to `fromBytes` */
|
|
65
|
+
string(bytes, options = {}) { return Bytename.fromBytes(bytes, options); },
|
|
66
|
+
/** @deprecated renamed to `toBytes` */
|
|
67
|
+
bytes(bytename) { return Bytename.toBytes(bytename); },
|
|
68
|
+
/** @deprecated renamed to `toHex` */
|
|
69
|
+
hex(bytename) { return Bytename.toHex(bytename); },
|
|
65
70
|
};
|
|
66
71
|
//# sourceMappingURL=bytename.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bytename.js","sourceRoot":"","sources":["../../../s/data/bytename/bytename.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,GAAG,EAAC,MAAM,WAAW,CAAA;AAC7B,OAAO,EAAC,KAAK,EAAC,MAAM,aAAa,CAAA;AACjC,OAAO,EAAC,QAAQ,EAAC,MAAM,qBAAqB,CAAA;AAC5C,OAAO,EAAC,QAAQ,EAAC,MAAM,qBAAqB,CAAA;AAQ5C
|
|
1
|
+
{"version":3,"file":"bytename.js","sourceRoot":"","sources":["../../../s/data/bytename/bytename.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,GAAG,EAAC,MAAM,WAAW,CAAA;AAC7B,OAAO,EAAC,KAAK,EAAC,MAAM,aAAa,CAAA;AACjC,OAAO,EAAC,QAAQ,EAAC,MAAM,qBAAqB,CAAA;AAC5C,OAAO,EAAC,QAAQ,EAAC,MAAM,qBAAqB,CAAA;AAQ5C;;;;;GAKG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG;IACvB,QAAQ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OAAO,EAAE,CAAC,CAAA;YAC9C,OAAO,MAAM,CAAA;QACd,CAAC,CAAC,CAAC,CAAA;IACJ,CAAC;IAED,KAAK,CAAC,QAAgB;QACrB,OAAO,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAA;IAC9C,CAAC;IAED,OAAO,CAAC,GAAW,EAAE,OAAkC;QACtD,OAAO,QAAQ,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC,CAAA;IACnD,CAAC;IAED,yCAAyC;IACzC,MAAM,CAAC,KAAiB,EAAE,UAAoC,EAAE,IAAI,OAAO,QAAQ,CAAC,SAAS,CAAC,KAAK,EAAE,OAAO,CAAC,CAAA,CAAC,CAAC;IAE/G,uCAAuC;IACvC,KAAK,CAAC,QAAgB,IAAI,OAAO,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAA,CAAC,CAAC;IAE7D,qCAAqC;IACrC,GAAG,CAAC,QAAgB,IAAI,OAAO,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAA,CAAC,CAAC;CACzD,CAAA"}
|
|
@@ -7,21 +7,21 @@ function good(bytes) {
|
|
|
7
7
|
}
|
|
8
8
|
export default Science.suite({
|
|
9
9
|
"bytes->string->bytes": test(async () => {
|
|
10
|
-
const text = Bytename.
|
|
10
|
+
const text = Bytename.fromBytes(deadbeef);
|
|
11
11
|
expect(text).is("ribmug.hilmun");
|
|
12
|
-
good(Bytename.
|
|
12
|
+
good(Bytename.toBytes(text));
|
|
13
13
|
}),
|
|
14
14
|
"zero bytes": test(async () => {
|
|
15
|
-
const text = Bytename.
|
|
15
|
+
const text = Bytename.fromBytes(new Uint8Array([]));
|
|
16
16
|
expect(text).is("");
|
|
17
17
|
}),
|
|
18
18
|
"one byte": test(async () => {
|
|
19
|
-
const text = Bytename.
|
|
19
|
+
const text = Bytename.fromBytes(new Uint8Array([0x00]));
|
|
20
20
|
expect(text).is("doz");
|
|
21
21
|
}),
|
|
22
22
|
"groupings": test(async () => {
|
|
23
23
|
const bytes = new Uint8Array([...deadbeef, ...deadbeef]);
|
|
24
|
-
const text = Bytename.
|
|
24
|
+
const text = Bytename.fromBytes(bytes, {
|
|
25
25
|
groupSize: 2,
|
|
26
26
|
groupSeparator: " ",
|
|
27
27
|
wordSeparator: ".",
|
|
@@ -29,13 +29,13 @@ export default Science.suite({
|
|
|
29
29
|
expect(text).is("ribmug.hilmun ribmug.hilmun");
|
|
30
30
|
}),
|
|
31
31
|
"wordsep": Science.suite({
|
|
32
|
-
"underscore": test(async () => good(Bytename.
|
|
33
|
-
"uppercase": test(async () => good(Bytename.
|
|
34
|
-
"dots": test(async () => good(Bytename.
|
|
35
|
-
"crushed": test(async () => good(Bytename.
|
|
36
|
-
"space": test(async () => good(Bytename.
|
|
37
|
-
"spaces": test(async () => good(Bytename.
|
|
38
|
-
"whitespace": test(async () => good(Bytename.
|
|
32
|
+
"underscore": test(async () => good(Bytename.toBytes("ribmug_hilmun"))),
|
|
33
|
+
"uppercase": test(async () => good(Bytename.toBytes("RIBMUG_HILMUN"))),
|
|
34
|
+
"dots": test(async () => good(Bytename.toBytes("ribmug.hilmun"))),
|
|
35
|
+
"crushed": test(async () => good(Bytename.toBytes("ribmughilmun"))),
|
|
36
|
+
"space": test(async () => good(Bytename.toBytes("ribmug hilmun"))),
|
|
37
|
+
"spaces": test(async () => good(Bytename.toBytes("ribmug hilmun"))),
|
|
38
|
+
"whitespace": test(async () => good(Bytename.toBytes("\n ribmug \n \t \n hilmun \n"))),
|
|
39
39
|
}),
|
|
40
40
|
});
|
|
41
41
|
//# sourceMappingURL=bytename.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bytename.test.js","sourceRoot":"","sources":["../../../s/data/bytename/bytename.test.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,KAAK,EAAC,MAAM,aAAa,CAAA;AACjC,OAAO,EAAC,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