@e280/stz 0.0.0-14 → 0.0.0-16
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/s/data/bytename/thumbprint.test.ts +2 -2
- package/s/data/bytename/thumbprint.ts +5 -5
- 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/x/data/bytename/thumbprint.d.ts +1 -1
- package/x/data/bytename/thumbprint.js +5 -5
- package/x/data/bytename/thumbprint.js.map +1 -1
- package/x/data/bytename/thumbprint.test.js +2 -2
- package/x/data/bytename/thumbprint.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,7 +4,7 @@ import {Hex} from "../hex.js"
|
|
|
4
4
|
import {Bytes} from "../bytes.js"
|
|
5
5
|
import {Thumbprint} from "./thumbprint.js"
|
|
6
6
|
|
|
7
|
-
const sampleThumbprint = "nodlyn.fasrep::
|
|
7
|
+
const sampleThumbprint = "nodlyn.fasrep.habbud.ralwel::Avo7gFmdWMRHkwsD149mcaBoZdS69iXuJ"
|
|
8
8
|
const sampleHex = "88e8c3fad1028fcf6ce5ac491578850f4d833336feca03b608265501c3019d59"
|
|
9
9
|
const sampleBytes = Hex.bytes(sampleHex)
|
|
10
10
|
|
|
@@ -32,7 +32,7 @@ export default Science.suite({
|
|
|
32
32
|
}),
|
|
33
33
|
|
|
34
34
|
"partially": Science.suite({
|
|
35
|
-
"normal": test(async() => expect(Thumbprint.toBytes(
|
|
35
|
+
"normal": test(async() => expect(Thumbprint.toBytes(sampleThumbprint).length).ok()),
|
|
36
36
|
"nothing": test(async() => expect(Thumbprint.toBytes("").length).is(0)),
|
|
37
37
|
"no-bulk": test(async() => expect(Thumbprint.toBytes("nodlyn.fasrep").length).ok()),
|
|
38
38
|
"one-byte": test(async() => expect(Thumbprint.toBytes("nod").length).is(1)),
|
|
@@ -18,7 +18,7 @@ export type ThumbprintData = {
|
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
20
|
* Thumbprint is a friendly presentation format for arbitrary binary data.
|
|
21
|
-
* - looks like "nodlyn.fasrep::
|
|
21
|
+
* - looks like "nodlyn.fasrep.habbud.ralwel::Avo7gFmdWMRHkwsD149mcaBoZdS69iXuJ"
|
|
22
22
|
* - the "sigil" is the first bytes that are shown in bytename format
|
|
23
23
|
* - the "bulk" is the rest of the data in base58
|
|
24
24
|
* - originally designed to be a nice way to present 256-bit ids
|
|
@@ -28,7 +28,7 @@ export const Thumbprint = {
|
|
|
28
28
|
defaults: (<ThumbprintOptions>{
|
|
29
29
|
delimiter: "::",
|
|
30
30
|
sigilDelimiter: ".",
|
|
31
|
-
sigilByteCount:
|
|
31
|
+
sigilByteCount: 8,
|
|
32
32
|
}),
|
|
33
33
|
|
|
34
34
|
parse(thumbprint: string): ThumbprintData {
|
|
@@ -39,14 +39,14 @@ export const Thumbprint = {
|
|
|
39
39
|
|
|
40
40
|
if (parts.length < 2) {
|
|
41
41
|
const sigil = parts.join(".")
|
|
42
|
-
const bytes = Bytename.
|
|
42
|
+
const bytes = Bytename.toBytes(sigil)
|
|
43
43
|
return {bytes, sigil, bulk: "", thumbprint}
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
const bulk = parts.pop()!
|
|
47
47
|
const sigil = parts.join(".")
|
|
48
48
|
const bytes = new Uint8Array([
|
|
49
|
-
...Bytename.
|
|
49
|
+
...Bytename.toBytes(sigil),
|
|
50
50
|
...Base58.bytes(bulk),
|
|
51
51
|
])
|
|
52
52
|
|
|
@@ -59,7 +59,7 @@ export const Thumbprint = {
|
|
|
59
59
|
= {...Thumbprint.defaults, ...options}
|
|
60
60
|
|
|
61
61
|
const sigil = (bytes.length > 0)
|
|
62
|
-
? Bytename.
|
|
62
|
+
? Bytename.fromBytes(bytes.slice(0, sigilByteCount), {
|
|
63
63
|
wordSeparator: sigilDelimiter,
|
|
64
64
|
groupSeparator: sigilDelimiter,
|
|
65
65
|
})
|
|
@@ -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,EAAoB;QAC3B,SAAS,EAAE,CAAC;QACZ,aAAa,EAAE,GAAG;QAClB,cAAc,EAAE,GAAG;KAClB;IAEF,MAAM,CAAC,SAAiB,EAAE,OAAkC;QAC3D,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,CAAA;QACrC,OAAO,IAAI,CAAC,SAAS,C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AAC,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,QAAQ,EAAC,MAAM,eAAe,CAAA;AACtC,OAAO,EAAC,OAAO,EAAE,IAAI,EAAE,MAAM,EAAC,MAAM,eAAe,CAAA;AAEnD,MAAM,QAAQ,GAAG,IAAI,UAAU,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAA;AAEzD,SAAS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AAG,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC;QACjE,QAAQ,EAAE,IAAI,CAAC,KAAK,IAAG,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC,CAAC;QACnE,YAAY,EAAE,IAAI,CAAC,KAAK,IAAG,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,8BAA8B,CAAC,CAAC,CAAC;KACrF,CAAC;CACF,CAAC,CAAA"}
|
|
@@ -11,7 +11,7 @@ export type ThumbprintData = {
|
|
|
11
11
|
};
|
|
12
12
|
/**
|
|
13
13
|
* Thumbprint is a friendly presentation format for arbitrary binary data.
|
|
14
|
-
* - looks like "nodlyn.fasrep::
|
|
14
|
+
* - looks like "nodlyn.fasrep.habbud.ralwel::Avo7gFmdWMRHkwsD149mcaBoZdS69iXuJ"
|
|
15
15
|
* - the "sigil" is the first bytes that are shown in bytename format
|
|
16
16
|
* - the "bulk" is the rest of the data in base58
|
|
17
17
|
* - originally designed to be a nice way to present 256-bit ids
|
|
@@ -3,7 +3,7 @@ import { Base58 } from "../base58.js";
|
|
|
3
3
|
import { Bytename } from "./bytename.js";
|
|
4
4
|
/**
|
|
5
5
|
* Thumbprint is a friendly presentation format for arbitrary binary data.
|
|
6
|
-
* - looks like "nodlyn.fasrep::
|
|
6
|
+
* - looks like "nodlyn.fasrep.habbud.ralwel::Avo7gFmdWMRHkwsD149mcaBoZdS69iXuJ"
|
|
7
7
|
* - the "sigil" is the first bytes that are shown in bytename format
|
|
8
8
|
* - the "bulk" is the rest of the data in base58
|
|
9
9
|
* - originally designed to be a nice way to present 256-bit ids
|
|
@@ -13,7 +13,7 @@ export const Thumbprint = {
|
|
|
13
13
|
defaults: {
|
|
14
14
|
delimiter: "::",
|
|
15
15
|
sigilDelimiter: ".",
|
|
16
|
-
sigilByteCount:
|
|
16
|
+
sigilByteCount: 8,
|
|
17
17
|
},
|
|
18
18
|
parse(thumbprint) {
|
|
19
19
|
thumbprint = thumbprint.trim();
|
|
@@ -22,13 +22,13 @@ export const Thumbprint = {
|
|
|
22
22
|
.map(s => s.trim());
|
|
23
23
|
if (parts.length < 2) {
|
|
24
24
|
const sigil = parts.join(".");
|
|
25
|
-
const bytes = Bytename.
|
|
25
|
+
const bytes = Bytename.toBytes(sigil);
|
|
26
26
|
return { bytes, sigil, bulk: "", thumbprint };
|
|
27
27
|
}
|
|
28
28
|
const bulk = parts.pop();
|
|
29
29
|
const sigil = parts.join(".");
|
|
30
30
|
const bytes = new Uint8Array([
|
|
31
|
-
...Bytename.
|
|
31
|
+
...Bytename.toBytes(sigil),
|
|
32
32
|
...Base58.bytes(bulk),
|
|
33
33
|
]);
|
|
34
34
|
return { bytes, sigil, bulk, thumbprint };
|
|
@@ -37,7 +37,7 @@ export const Thumbprint = {
|
|
|
37
37
|
fromBytes(bytes, options = {}) {
|
|
38
38
|
const { sigilByteCount, sigilDelimiter, delimiter } = { ...Thumbprint.defaults, ...options };
|
|
39
39
|
const sigil = (bytes.length > 0)
|
|
40
|
-
? Bytename.
|
|
40
|
+
? Bytename.fromBytes(bytes.slice(0, sigilByteCount), {
|
|
41
41
|
wordSeparator: sigilDelimiter,
|
|
42
42
|
groupSeparator: sigilDelimiter,
|
|
43
43
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"thumbprint.js","sourceRoot":"","sources":["../../../s/data/bytename/thumbprint.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,GAAG,EAAC,MAAM,WAAW,CAAA;AAC7B,OAAO,EAAC,MAAM,EAAC,MAAM,cAAc,CAAA;AACnC,OAAO,EAAC,QAAQ,EAAC,MAAM,eAAe,CAAA;AAetC;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG;IACzB,QAAQ,EAAsB;QAC7B,SAAS,EAAE,IAAI;QACf,cAAc,EAAE,GAAG;QACnB,cAAc,EAAE,CAAC;K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2
2
|
import { Hex } from "../hex.js";
|
|
3
3
|
import { Bytes } from "../bytes.js";
|
|
4
4
|
import { Thumbprint } from "./thumbprint.js";
|
|
5
|
-
const sampleThumbprint = "nodlyn.fasrep::
|
|
5
|
+
const sampleThumbprint = "nodlyn.fasrep.habbud.ralwel::Avo7gFmdWMRHkwsD149mcaBoZdS69iXuJ";
|
|
6
6
|
const sampleHex = "88e8c3fad1028fcf6ce5ac491578850f4d833336feca03b608265501c3019d59";
|
|
7
7
|
const sampleBytes = Hex.bytes(sampleHex);
|
|
8
8
|
function good(bytes) {
|
|
@@ -25,7 +25,7 @@ export default Science.suite({
|
|
|
25
25
|
expect(Bytes.eq(Thumbprint.toBytes(text), new Uint8Array([0x00]))).ok();
|
|
26
26
|
}),
|
|
27
27
|
"partially": Science.suite({
|
|
28
|
-
"normal": test(async () => expect(Thumbprint.toBytes(
|
|
28
|
+
"normal": test(async () => expect(Thumbprint.toBytes(sampleThumbprint).length).ok()),
|
|
29
29
|
"nothing": test(async () => expect(Thumbprint.toBytes("").length).is(0)),
|
|
30
30
|
"no-bulk": test(async () => expect(Thumbprint.toBytes("nodlyn.fasrep").length).ok()),
|
|
31
31
|
"one-byte": test(async () => expect(Thumbprint.toBytes("nod").length).is(1)),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"thumbprint.test.js","sourceRoot":"","sources":["../../../s/data/bytename/thumbprint.test.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,OAAO,EAAE,IAAI,EAAE,MAAM,EAAC,MAAM,eAAe,CAAA;AACnD,OAAO,EAAC,GAAG,EAAC,MAAM,WAAW,CAAA;AAC7B,OAAO,EAAC,KAAK,EAAC,MAAM,aAAa,CAAA;AACjC,OAAO,EAAC,UAAU,EAAC,MAAM,iBAAiB,CAAA;AAE1C,MAAM,gBAAgB,GAAG,
|
|
1
|
+
{"version":3,"file":"thumbprint.test.js","sourceRoot":"","sources":["../../../s/data/bytename/thumbprint.test.ts"],"names":[],"mappings":"A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