@e280/stz 0.2.10 → 0.2.12
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 +108 -83
- package/package.json +2 -2
- package/s/data/base-x-codecs.ts +11 -0
- package/s/data/base-x.ts +2 -2
- package/s/data/bytename/bytename.test.ts +16 -16
- package/s/data/bytename/bytename.ts +19 -16
- package/s/data/bytename/thumbprint.test.ts +25 -25
- package/s/data/bytename/thumbprint.ts +54 -37
- package/s/data/bytes.ts +4 -1
- package/s/data/data.test.ts +19 -17
- package/s/data/{base58.ts → legacy/base58.ts} +3 -2
- package/s/data/{base64.ts → legacy/base64.ts} +3 -2
- package/s/data/{base64url.ts → legacy/base64url.ts} +3 -2
- package/s/data/{hex.ts → legacy/hex.ts} +3 -2
- package/s/data/nomen/grammar.ts +2 -2
- package/s/data/nomen/nomen.ts +2 -2
- package/s/data/txt.ts +6 -3
- package/s/deep/{parts/equal.test.ts → equal.test.ts} +33 -33
- package/s/deep/{parts/equal.ts → equal.ts} +2 -2
- package/s/deep/{parts/freeze.ts → freeze.ts} +2 -3
- package/s/deep/index.barrel.ts +5 -0
- package/s/deep/index.test.ts +10 -0
- package/s/deep/index.ts +3 -0
- package/s/g/map.ts +36 -0
- package/s/g/pool.ts +24 -0
- package/s/{set-g.ts → g/set.ts} +4 -1
- package/s/g/weak-map.ts +32 -0
- package/s/index.ts +15 -8
- package/s/pubsub.ts +1 -1
- package/s/tests.test.ts +5 -9
- package/s/time.ts +15 -12
- package/s/toq/index.ts +3 -0
- package/s/toq/toq.test.ts +46 -0
- package/s/toq/toq.ts +62 -0
- package/x/data/base-x-codecs.d.ts +8 -0
- package/x/data/base-x-codecs.js +9 -0
- package/x/data/base-x-codecs.js.map +1 -0
- package/x/data/base-x.js +2 -2
- package/x/data/bytename/bytename.d.ts +13 -4
- package/x/data/bytename/bytename.js +16 -14
- package/x/data/bytename/bytename.js.map +1 -1
- package/x/data/bytename/bytename.test.js +16 -16
- package/x/data/bytename/bytename.test.js.map +1 -1
- package/x/data/bytename/thumbprint.d.ts +32 -11
- package/x/data/bytename/thumbprint.js +44 -35
- package/x/data/bytename/thumbprint.js.map +1 -1
- package/x/data/bytename/thumbprint.test.js +25 -25
- package/x/data/bytename/thumbprint.test.js.map +1 -1
- package/x/data/bytes.d.ts +5 -0
- package/x/data/bytes.js +3 -1
- package/x/data/bytes.js.map +1 -1
- package/x/data/data.test.d.ts +37 -0
- package/x/data/data.test.js +18 -17
- package/x/data/data.test.js.map +1 -1
- package/x/data/{base58.d.ts → legacy/base58.d.ts} +1 -0
- package/x/data/{base58.js → legacy/base58.js} +3 -2
- package/x/data/legacy/base58.js.map +1 -0
- package/x/data/{base64.d.ts → legacy/base64.d.ts} +1 -0
- package/x/data/{base64.js → legacy/base64.js} +3 -2
- package/x/data/legacy/base64.js.map +1 -0
- package/x/data/{base64url.d.ts → legacy/base64url.d.ts} +1 -0
- package/x/data/{base64url.js → legacy/base64url.js} +3 -2
- package/x/data/legacy/base64url.js.map +1 -0
- package/x/data/{hex.d.ts → legacy/hex.d.ts} +1 -0
- package/x/data/{hex.js → legacy/hex.js} +3 -2
- package/x/data/legacy/hex.js.map +1 -0
- package/x/data/nomen/grammar.js +2 -2
- package/x/data/nomen/nomen.js +2 -2
- package/x/data/txt.d.ts +9 -0
- package/x/data/txt.js +5 -3
- package/x/data/txt.js.map +1 -1
- package/x/deep/clone.js.map +1 -0
- package/x/deep/clone.test.js.map +1 -0
- package/x/deep/equal.d.ts +1 -0
- package/x/deep/{parts/equal.js → equal.js} +2 -2
- package/x/deep/equal.js.map +1 -0
- package/x/deep/{parts/equal.test.js → equal.test.js} +33 -33
- package/x/deep/equal.test.js.map +1 -0
- package/x/deep/freeze.d.ts +1 -0
- package/x/deep/{parts/freeze.js → freeze.js} +2 -2
- package/x/deep/freeze.js.map +1 -0
- package/x/deep/index.barrel.d.ts +3 -0
- package/x/deep/index.barrel.js +4 -0
- package/x/deep/index.barrel.js.map +1 -0
- package/x/deep/index.d.ts +1 -0
- package/x/deep/index.js +2 -0
- package/x/deep/index.js.map +1 -0
- package/x/deep/{deep.test.d.ts → index.test.d.ts} +15 -1
- package/x/deep/index.test.js +8 -0
- package/x/deep/index.test.js.map +1 -0
- package/x/g/map.d.ts +10 -0
- package/x/g/map.js +30 -0
- package/x/g/map.js.map +1 -0
- package/x/g/pool.d.ts +12 -0
- package/x/g/pool.js +17 -0
- package/x/g/pool.js.map +1 -0
- package/x/{set-g.d.ts → g/set.d.ts} +3 -1
- package/x/{set-g.js → g/set.js} +4 -2
- package/x/g/set.js.map +1 -0
- package/x/g/weak-map.d.ts +9 -0
- package/x/g/weak-map.js +27 -0
- package/x/g/weak-map.js.map +1 -0
- package/x/index.d.ts +13 -8
- package/x/index.js +13 -8
- package/x/index.js.map +1 -1
- package/x/pubsub.d.ts +1 -1
- package/x/tests.test.js +5 -9
- package/x/tests.test.js.map +1 -1
- package/x/time.d.ts +19 -0
- package/x/time.js +14 -12
- package/x/time.js.map +1 -1
- package/x/toq/index.d.ts +1 -0
- package/x/toq/index.js +2 -0
- package/x/toq/index.js.map +1 -0
- package/x/toq/toq.d.ts +4 -0
- package/x/toq/toq.js +48 -0
- package/x/toq/toq.js.map +1 -0
- package/x/toq/toq.test.d.ts +9 -0
- package/x/toq/toq.test.js +40 -0
- package/x/toq/toq.test.js.map +1 -0
- package/s/data/bytename/index.ts +0 -4
- package/s/deep/deep.test.ts +0 -8
- package/s/deep/deep.ts +0 -11
- package/s/map-g.ts +0 -79
- package/x/clone/clone.js.map +0 -1
- package/x/clone/clone.test.js.map +0 -1
- package/x/data/base58.js.map +0 -1
- package/x/data/base64.js.map +0 -1
- package/x/data/base64url.js.map +0 -1
- package/x/data/bytename/index.d.ts +0 -2
- package/x/data/bytename/index.js +0 -3
- package/x/data/bytename/index.js.map +0 -1
- package/x/data/hex.js.map +0 -1
- package/x/deep/deep.d.ts +0 -7
- package/x/deep/deep.js +0 -9
- package/x/deep/deep.js.map +0 -1
- package/x/deep/deep.test.js +0 -6
- package/x/deep/deep.test.js.map +0 -1
- package/x/deep/parts/equal.d.ts +0 -1
- package/x/deep/parts/equal.js.map +0 -1
- package/x/deep/parts/equal.test.js.map +0 -1
- package/x/deep/parts/freeze.d.ts +0 -1
- package/x/deep/parts/freeze.js.map +0 -1
- package/x/map-g.d.ts +0 -24
- package/x/map-g.js +0 -65
- package/x/map-g.js.map +0 -1
- package/x/set-g.js.map +0 -1
- /package/s/{clone → deep}/clone.test.ts +0 -0
- /package/s/{clone → deep}/clone.ts +0 -0
- /package/x/{clone → deep}/clone.d.ts +0 -0
- /package/x/{clone → deep}/clone.js +0 -0
- /package/x/{clone → deep}/clone.test.d.ts +0 -0
- /package/x/{clone → deep}/clone.test.js +0 -0
- /package/x/deep/{parts/equal.test.d.ts → equal.test.d.ts} +0 -0
package/s/g/weak-map.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
|
|
2
|
+
/** extended weak map with handy methods like `require` and `guarantee` */
|
|
3
|
+
export class GWeakMap<K extends WeakKey, V> extends WeakMap<K, V> {
|
|
4
|
+
static require<K extends WeakKey, V>(map: WeakMap<K, V>, key: K) {
|
|
5
|
+
if (map.has(key))
|
|
6
|
+
return map.get(key) as V
|
|
7
|
+
else
|
|
8
|
+
throw new Error(`required key not found`)
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
static guarantee<K extends WeakKey, V>(map: WeakMap<K, V>, key: K, make: () => V) {
|
|
12
|
+
if (map.has(key))
|
|
13
|
+
return map.get(key)!
|
|
14
|
+
else {
|
|
15
|
+
const value = make()
|
|
16
|
+
map.set(key, value)
|
|
17
|
+
return value
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
require(key: K) {
|
|
22
|
+
return GWeakMap.require(this, key)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
guarantee(key: K, make: () => V) {
|
|
26
|
+
return GWeakMap.guarantee(this, key, make)
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** @deprecated renamed to `GWeakMap` */
|
|
31
|
+
export const WeakMapG = GWeakMap
|
|
32
|
+
|
package/s/index.ts
CHANGED
|
@@ -1,20 +1,29 @@
|
|
|
1
1
|
|
|
2
|
-
export * from "./data/bytename/
|
|
2
|
+
export * from "./data/bytename/bytename.js"
|
|
3
|
+
export * from "./data/bytename/thumbprint.js"
|
|
4
|
+
export * from "./data/legacy/base58.js"
|
|
5
|
+
export * from "./data/legacy/base64.js"
|
|
6
|
+
export * from "./data/legacy/base64url.js"
|
|
7
|
+
export * from "./data/legacy/hex.js"
|
|
8
|
+
export * from "./data/base-x-codecs.js"
|
|
3
9
|
export * from "./data/base-x.js"
|
|
4
|
-
export * from "./data/base58.js"
|
|
5
|
-
export * from "./data/base64.js"
|
|
6
|
-
export * from "./data/base64url.js"
|
|
7
10
|
export * from "./data/bytes.js"
|
|
8
|
-
export * from "./data/hex.js"
|
|
9
11
|
export * from "./data/txt.js"
|
|
10
12
|
|
|
11
13
|
export * from "./debounce/debounce.js"
|
|
12
14
|
export * from "./debounce/types.js"
|
|
13
15
|
|
|
14
|
-
export * from "./deep/
|
|
16
|
+
export * from "./deep/index.js"
|
|
17
|
+
|
|
18
|
+
export * from "./g/map.js"
|
|
19
|
+
export * from "./g/pool.js"
|
|
20
|
+
export * from "./g/set.js"
|
|
21
|
+
export * from "./g/weak-map.js"
|
|
15
22
|
|
|
16
23
|
export * from "./queue/queue.js"
|
|
17
24
|
|
|
25
|
+
export * from "./toq/index.js"
|
|
26
|
+
|
|
18
27
|
export * from "./coalesce.js"
|
|
19
28
|
export * from "./collect.js"
|
|
20
29
|
export * from "./concurrent.js"
|
|
@@ -32,7 +41,6 @@ export * from "./ev.js"
|
|
|
32
41
|
export * from "./hat.js"
|
|
33
42
|
export * from "./id-counter.js"
|
|
34
43
|
export * from "./is.js"
|
|
35
|
-
export * from "./map-g.js"
|
|
36
44
|
export * from "./nap.js"
|
|
37
45
|
export * from "./ob.js"
|
|
38
46
|
export * from "./once.js"
|
|
@@ -40,7 +48,6 @@ export * from "./pipe.js"
|
|
|
40
48
|
export * from "./provide.js"
|
|
41
49
|
export * from "./pubsub.js"
|
|
42
50
|
export * from "./scope.js"
|
|
43
|
-
export * from "./set-g.js"
|
|
44
51
|
export * from "./templating.js"
|
|
45
52
|
export * from "./time.js"
|
|
46
53
|
export * from "./trash.js"
|
package/s/pubsub.ts
CHANGED
package/s/tests.test.ts
CHANGED
|
@@ -1,21 +1,17 @@
|
|
|
1
1
|
|
|
2
2
|
import {Science} from "@e280/science"
|
|
3
3
|
|
|
4
|
-
import clone from "./clone/clone.test.js"
|
|
5
|
-
import thumbprint from "./data/bytename/thumbprint.test.js"
|
|
6
|
-
import debounce from "./debounce/debounce.test.js"
|
|
7
|
-
import bytename from "./data/bytename/bytename.test.js"
|
|
8
|
-
import deep from "./deep/deep.test.js"
|
|
9
4
|
import data from "./data/data.test.js"
|
|
5
|
+
import debounce from "./debounce/debounce.test.js"
|
|
6
|
+
import deep from "./deep/index.test.js"
|
|
10
7
|
import queue from "./queue/queue.test.js"
|
|
8
|
+
import toq from "./toq/toq.test.js"
|
|
11
9
|
|
|
12
10
|
await Science.run({
|
|
13
|
-
|
|
14
|
-
bytename,
|
|
15
|
-
thumbprint,
|
|
11
|
+
data,
|
|
16
12
|
debounce,
|
|
17
13
|
deep,
|
|
18
|
-
data,
|
|
19
14
|
queue,
|
|
15
|
+
toq,
|
|
20
16
|
})
|
|
21
17
|
|
package/s/time.ts
CHANGED
|
@@ -1,22 +1,25 @@
|
|
|
1
1
|
|
|
2
|
-
export const
|
|
2
|
+
export const time = {
|
|
3
3
|
seconds: (n: number) => (n * 1000),
|
|
4
|
-
minutes: (n: number) => (n *
|
|
5
|
-
hours: (n: number) => (n *
|
|
6
|
-
days: (n: number) => (n *
|
|
4
|
+
minutes: (n: number) => (n * time.seconds(60)),
|
|
5
|
+
hours: (n: number) => (n * time.minutes(60)),
|
|
6
|
+
days: (n: number) => (n * time.hours(24)),
|
|
7
7
|
|
|
8
8
|
future: {
|
|
9
|
-
seconds: (n: number) => (Date.now() +
|
|
10
|
-
minutes: (n: number) => (Date.now() +
|
|
11
|
-
hours: (n: number) => (Date.now() +
|
|
12
|
-
days: (n: number) => (Date.now() +
|
|
9
|
+
seconds: (n: number) => (Date.now() + time.seconds(n)),
|
|
10
|
+
minutes: (n: number) => (Date.now() + time.minutes(n)),
|
|
11
|
+
hours: (n: number) => (Date.now() + time.hours(n)),
|
|
12
|
+
days: (n: number) => (Date.now() + time.days(n)),
|
|
13
13
|
},
|
|
14
14
|
|
|
15
15
|
past: {
|
|
16
|
-
seconds: (n: number) => (Date.now() -
|
|
17
|
-
minutes: (n: number) => (Date.now() -
|
|
18
|
-
hours: (n: number) => (Date.now() -
|
|
19
|
-
days: (n: number) => (Date.now() -
|
|
16
|
+
seconds: (n: number) => (Date.now() - time.seconds(n)),
|
|
17
|
+
minutes: (n: number) => (Date.now() - time.minutes(n)),
|
|
18
|
+
hours: (n: number) => (Date.now() - time.hours(n)),
|
|
19
|
+
days: (n: number) => (Date.now() - time.days(n)),
|
|
20
20
|
},
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
+
/** @deprecated renamed to `time` */
|
|
24
|
+
export const Time = time
|
|
25
|
+
|
package/s/toq/index.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
|
|
2
|
+
import {expect, Science, test} from "@e280/science"
|
|
3
|
+
import {toq} from "./index.js"
|
|
4
|
+
import {txt} from "../data/txt.js"
|
|
5
|
+
import {deep} from "../deep/index.js"
|
|
6
|
+
|
|
7
|
+
export default Science.suite({
|
|
8
|
+
"roundtrip one file": test(async() => {
|
|
9
|
+
const a: toq.Entry[] = [["hello.txt", txt.toBytes("hello world")]]
|
|
10
|
+
const b = [...toq.unpack(toq.pack(a))]
|
|
11
|
+
expect(deep.equal(a, b)).ok()
|
|
12
|
+
}),
|
|
13
|
+
|
|
14
|
+
"roundtrip two files": test(async() => {
|
|
15
|
+
const a: toq.Entry[] = [
|
|
16
|
+
["hello.txt", txt.toBytes("hello world")],
|
|
17
|
+
["data.binary", new Uint8Array([0xDE, 0xAD, 0xBE, 0xEF])],
|
|
18
|
+
]
|
|
19
|
+
const b = [...toq.unpack(toq.pack(a))]
|
|
20
|
+
expect(deep.equal(a, b)).ok()
|
|
21
|
+
}),
|
|
22
|
+
|
|
23
|
+
"wrong magic bytes cause failure": test(async() => {
|
|
24
|
+
const good = toq.pack([["hello.txt", txt.toBytes("hello world")]])
|
|
25
|
+
const bad = new Uint8Array([...good])
|
|
26
|
+
bad.set([0xDE, 0xAD, 0xBE, 0xEF], 0)
|
|
27
|
+
expect(toq.is(good)).is(true)
|
|
28
|
+
expect(toq.is(bad)).is(false)
|
|
29
|
+
expect(() => [...toq.unpack(bad)]).throws()
|
|
30
|
+
}),
|
|
31
|
+
|
|
32
|
+
"from map": test(async() => {
|
|
33
|
+
const files = new Map<string, Uint8Array>()
|
|
34
|
+
files.set("hello.txt", txt.toBytes("hello world"))
|
|
35
|
+
files.set("deadbeef.data", new Uint8Array([0xDE, 0xAD, 0xBE, 0xEF]))
|
|
36
|
+
const archive = toq.pack(files)
|
|
37
|
+
expect(toq.is(archive)).ok()
|
|
38
|
+
}),
|
|
39
|
+
|
|
40
|
+
"to map": test(async() => {
|
|
41
|
+
const archive = toq.pack([["hello.txt", txt.toBytes("hello world")]])
|
|
42
|
+
const files = new Map(toq.unpack(archive))
|
|
43
|
+
expect(files.has("hello.txt")).ok()
|
|
44
|
+
}),
|
|
45
|
+
})
|
|
46
|
+
|
package/s/toq/toq.ts
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
|
|
2
|
+
import {txt} from "../data/txt.js"
|
|
3
|
+
import {bytes} from "../data/bytes.js"
|
|
4
|
+
|
|
5
|
+
export type Entry = [name: string, data: Uint8Array]
|
|
6
|
+
|
|
7
|
+
const u32len = 4
|
|
8
|
+
const magic = txt.toBytes("TOQ\x01")
|
|
9
|
+
|
|
10
|
+
function u32(n: number) {
|
|
11
|
+
const view = new DataView(new ArrayBuffer(u32len))
|
|
12
|
+
view.setUint32(0, n, true)
|
|
13
|
+
return new Uint8Array(view.buffer)
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function pack(items: Iterable<Entry>) {
|
|
17
|
+
return new Uint8Array([
|
|
18
|
+
...magic,
|
|
19
|
+
...[...items].flatMap(([name, data]) => {
|
|
20
|
+
const nameBytes = new TextEncoder().encode(name)
|
|
21
|
+
if (nameBytes.length > 255) throw new Error("name cannot exceed 255 bytes")
|
|
22
|
+
return [
|
|
23
|
+
nameBytes.length,
|
|
24
|
+
...nameBytes,
|
|
25
|
+
...u32(data.length),
|
|
26
|
+
...data,
|
|
27
|
+
]
|
|
28
|
+
})
|
|
29
|
+
])
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function* unpack(file: Uint8Array) {
|
|
33
|
+
if (!is(file)) throw new Error("file is not a toq archive")
|
|
34
|
+
|
|
35
|
+
const view = new DataView(file.buffer, file.byteOffset, file.byteLength)
|
|
36
|
+
let cursor = magic.length
|
|
37
|
+
|
|
38
|
+
while (cursor < file.length) {
|
|
39
|
+
const nameLen = file[cursor]
|
|
40
|
+
cursor += 1
|
|
41
|
+
|
|
42
|
+
const name = txt.fromBytes(file.slice(cursor, cursor + nameLen))
|
|
43
|
+
cursor += nameLen
|
|
44
|
+
|
|
45
|
+
const dataLen = view.getUint32(cursor, true)
|
|
46
|
+
cursor += u32len
|
|
47
|
+
|
|
48
|
+
if ((cursor + dataLen) > file.length) throw new Error("corrupt toq archive")
|
|
49
|
+
const data = file.slice(cursor, cursor + dataLen)
|
|
50
|
+
cursor += dataLen
|
|
51
|
+
|
|
52
|
+
yield [name, data] as Entry
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export function is(file: Uint8Array) {
|
|
57
|
+
return bytes.eq(
|
|
58
|
+
file.slice(0, magic.length),
|
|
59
|
+
magic,
|
|
60
|
+
)
|
|
61
|
+
}
|
|
62
|
+
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { BaseX } from "./base-x.js";
|
|
2
|
+
export declare const hex: BaseX;
|
|
3
|
+
export declare const base2: BaseX;
|
|
4
|
+
export declare const base36: BaseX;
|
|
5
|
+
export declare const base58: BaseX;
|
|
6
|
+
export declare const base62: BaseX;
|
|
7
|
+
export declare const base64: BaseX;
|
|
8
|
+
export declare const base64url: BaseX;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { BaseX } from "./base-x.js";
|
|
2
|
+
export const hex = new BaseX(BaseX.lexicons.hex);
|
|
3
|
+
export const base2 = new BaseX(BaseX.lexicons.base2);
|
|
4
|
+
export const base36 = new BaseX(BaseX.lexicons.base36);
|
|
5
|
+
export const base58 = new BaseX(BaseX.lexicons.base58);
|
|
6
|
+
export const base62 = new BaseX(BaseX.lexicons.base62);
|
|
7
|
+
export const base64 = new BaseX(BaseX.lexicons.base64);
|
|
8
|
+
export const base64url = new BaseX(BaseX.lexicons.base64url);
|
|
9
|
+
//# sourceMappingURL=base-x-codecs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base-x-codecs.js","sourceRoot":"","sources":["../../s/data/base-x-codecs.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,KAAK,EAAC,MAAM,aAAa,CAAA;AAEjC,MAAM,CAAC,MAAM,GAAG,GAAG,IAAI,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAA;AAChD,MAAM,CAAC,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;AACpD,MAAM,CAAC,MAAM,MAAM,GAAG,IAAI,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAA;AACtD,MAAM,CAAC,MAAM,MAAM,GAAG,IAAI,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAA;AACtD,MAAM,CAAC,MAAM,MAAM,GAAG,IAAI,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAA;AACtD,MAAM,CAAC,MAAM,MAAM,GAAG,IAAI,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAA;AACtD,MAAM,CAAC,MAAM,SAAS,GAAG,IAAI,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAA"}
|
package/x/data/base-x.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { bytes } from "./bytes.js";
|
|
2
2
|
export class BaseX {
|
|
3
3
|
lexicon;
|
|
4
4
|
static lexicons = Object.freeze({
|
|
@@ -141,7 +141,7 @@ export class BaseX {
|
|
|
141
141
|
return negative ? `${this.negativePrefix}${out}` : out;
|
|
142
142
|
}
|
|
143
143
|
random(count = 32) {
|
|
144
|
-
return this.fromBytes(
|
|
144
|
+
return this.fromBytes(bytes.random(count));
|
|
145
145
|
}
|
|
146
146
|
}
|
|
147
147
|
//# sourceMappingURL=base-x.js.map
|
|
@@ -9,11 +9,20 @@ export type BytenameOptions = {
|
|
|
9
9
|
* - each byte maps to a three-letter triplet
|
|
10
10
|
* - all delimiters are just sugar, parser doesn't care
|
|
11
11
|
*/
|
|
12
|
+
export declare const bytename: {
|
|
13
|
+
defaults: BytenameOptions;
|
|
14
|
+
random(byteCount: number, options?: Partial<BytenameOptions>): string;
|
|
15
|
+
fromBytes(b: Uint8Array, options?: Partial<BytenameOptions>): string;
|
|
16
|
+
toBytes(bname: string): Uint8Array<ArrayBuffer>;
|
|
17
|
+
toHex(bname: string): string;
|
|
18
|
+
fromHex(h: string, options?: Partial<BytenameOptions>): string;
|
|
19
|
+
};
|
|
20
|
+
/** @deprecated renamed to `bytename` */
|
|
12
21
|
export declare const Bytename: {
|
|
13
22
|
defaults: BytenameOptions;
|
|
14
23
|
random(byteCount: number, options?: Partial<BytenameOptions>): string;
|
|
15
|
-
fromBytes(
|
|
16
|
-
toBytes(
|
|
17
|
-
toHex(
|
|
18
|
-
fromHex(
|
|
24
|
+
fromBytes(b: Uint8Array, options?: Partial<BytenameOptions>): string;
|
|
25
|
+
toBytes(bname: string): Uint8Array<ArrayBuffer>;
|
|
26
|
+
toHex(bname: string): string;
|
|
27
|
+
fromHex(h: string, options?: Partial<BytenameOptions>): string;
|
|
19
28
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { bytes } from "../bytes.js";
|
|
2
|
+
import { hex } from "../base-x-codecs.js";
|
|
3
3
|
import { prefixes } from "./utils/prefixes.js";
|
|
4
4
|
import { suffixes } from "./utils/suffixes.js";
|
|
5
5
|
/**
|
|
@@ -8,21 +8,21 @@ import { suffixes } from "./utils/suffixes.js";
|
|
|
8
8
|
* - each byte maps to a three-letter triplet
|
|
9
9
|
* - all delimiters are just sugar, parser doesn't care
|
|
10
10
|
*/
|
|
11
|
-
export const
|
|
11
|
+
export const bytename = {
|
|
12
12
|
defaults: {
|
|
13
13
|
groupSize: 4,
|
|
14
14
|
wordSeparator: ".",
|
|
15
15
|
groupSeparator: " ",
|
|
16
16
|
},
|
|
17
17
|
random(byteCount, options) {
|
|
18
|
-
const
|
|
19
|
-
return this.fromBytes(
|
|
18
|
+
const b = bytes.random(byteCount);
|
|
19
|
+
return this.fromBytes(b, options);
|
|
20
20
|
},
|
|
21
|
-
fromBytes(
|
|
22
|
-
const { groupSize =
|
|
21
|
+
fromBytes(b, options = {}) {
|
|
22
|
+
const { groupSize = bytename.defaults.groupSize, wordSeparator = bytename.defaults.wordSeparator, groupSeparator = bytename.defaults.groupSeparator, } = options;
|
|
23
23
|
const words = [];
|
|
24
24
|
let currentWord = [];
|
|
25
|
-
|
|
25
|
+
b.forEach((byte, index) => {
|
|
26
26
|
const source = ((index % 2) === 0) ? prefixes : suffixes;
|
|
27
27
|
currentWord.push(source[byte]);
|
|
28
28
|
if (currentWord.length === 2) {
|
|
@@ -37,8 +37,8 @@ export const Bytename = {
|
|
|
37
37
|
grouped.push(words.slice(i, i + groupSize).join(wordSeparator));
|
|
38
38
|
return grouped.join(groupSeparator);
|
|
39
39
|
},
|
|
40
|
-
toBytes(
|
|
41
|
-
const letters =
|
|
40
|
+
toBytes(bname) {
|
|
41
|
+
const letters = bname
|
|
42
42
|
.toLowerCase()
|
|
43
43
|
.replace(/[^a-z]/g, ""); // strip everything except letters
|
|
44
44
|
const count = letters.length / 3;
|
|
@@ -55,11 +55,13 @@ export const Bytename = {
|
|
|
55
55
|
return number;
|
|
56
56
|
}));
|
|
57
57
|
},
|
|
58
|
-
toHex(
|
|
59
|
-
return
|
|
58
|
+
toHex(bname) {
|
|
59
|
+
return hex.fromBytes(bytename.toBytes(bname));
|
|
60
60
|
},
|
|
61
|
-
fromHex(
|
|
62
|
-
return
|
|
61
|
+
fromHex(h, options) {
|
|
62
|
+
return bytename.fromBytes(hex.toBytes(h), options);
|
|
63
63
|
},
|
|
64
64
|
};
|
|
65
|
+
/** @deprecated renamed to `bytename` */
|
|
66
|
+
export const Bytename = bytename;
|
|
65
67
|
//# sourceMappingURL=bytename.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bytename.js","sourceRoot":"","sources":["../../../s/data/bytename/bytename.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"bytename.js","sourceRoot":"","sources":["../../../s/data/bytename/bytename.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,KAAK,EAAC,MAAM,aAAa,CAAA;AACjC,OAAO,EAAC,GAAG,EAAC,MAAM,qBAAqB,CAAA;AACvC,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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O,EAAE,CAAC,CAAA;YAC9C,OAAO,MAAM,CAAA;QACd,CAAC,CAAC,CAAC,CAAA;IACJ,CAAC;IAED,KAAK,CAAC,KAAa;QAClB,OAAO,GAAG,CAAC,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAA;IAC9C,CAAC;IAED,OAAO,CAAC,CAAS,EAAE,OAAkC;QACpD,OAAO,QAAQ,CAAC,SAAS,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,CAAA;IACnD,CAAC;CACD,CAAA;AAED,wCAAwC;AACxC,MAAM,CAAC,MAAM,QAAQ,GAAG,QAAQ,CAAA"}
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { bytes } from "../bytes.js";
|
|
2
|
+
import { bytename } from "./bytename.js";
|
|
3
3
|
import { Science, test, expect } from "@e280/science";
|
|
4
4
|
const deadbeef = new Uint8Array([0xDE, 0xAD, 0xBE, 0xEF]);
|
|
5
|
-
function good(
|
|
6
|
-
expect(
|
|
5
|
+
function good(b) {
|
|
6
|
+
expect(bytes.eq(b, deadbeef)).ok();
|
|
7
7
|
}
|
|
8
8
|
export default Science.suite({
|
|
9
9
|
"bytes->string->bytes": test(async () => {
|
|
10
|
-
const text =
|
|
10
|
+
const text = bytename.fromBytes(deadbeef);
|
|
11
11
|
expect(text).is("ribmug.hilmun");
|
|
12
|
-
good(
|
|
12
|
+
good(bytename.toBytes(text));
|
|
13
13
|
}),
|
|
14
14
|
"zero bytes": test(async () => {
|
|
15
|
-
const text =
|
|
15
|
+
const text = bytename.fromBytes(new Uint8Array([]));
|
|
16
16
|
expect(text).is("");
|
|
17
17
|
}),
|
|
18
18
|
"one byte": test(async () => {
|
|
19
|
-
const text =
|
|
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 =
|
|
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(
|
|
33
|
-
"uppercase": test(async () => good(
|
|
34
|
-
"dots": test(async () => good(
|
|
35
|
-
"crushed": test(async () => good(
|
|
36
|
-
"space": test(async () => good(
|
|
37
|
-
"spaces": test(async () => good(
|
|
38
|
-
"whitespace": test(async () => good(
|
|
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,MAA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C,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"}
|
|
@@ -4,11 +4,15 @@ export type ThumbprintOptions = {
|
|
|
4
4
|
previewBytes: number;
|
|
5
5
|
};
|
|
6
6
|
export type ThumbprintData = {
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
raw: Uint8Array;
|
|
8
|
+
full: string;
|
|
9
9
|
preview: string;
|
|
10
10
|
bulk: string;
|
|
11
11
|
sigil: string;
|
|
12
|
+
/** @deprecated renamed to `raw` */
|
|
13
|
+
readonly bytes: Uint8Array;
|
|
14
|
+
/** @deprecated renamed to `full` */
|
|
15
|
+
readonly thumbprint: string;
|
|
12
16
|
};
|
|
13
17
|
/**
|
|
14
18
|
* Thumbprint is a friendly presentation format for arbitrary binary data.
|
|
@@ -18,19 +22,36 @@ export type ThumbprintData = {
|
|
|
18
22
|
* - the sigil: "nodlyn.fasrep" (shorter part of the bytename)
|
|
19
23
|
* - originally designed to be a nice way to present 256-bit ids, but can actually represent any number of bytes
|
|
20
24
|
*/
|
|
25
|
+
export declare const thumbprint: {
|
|
26
|
+
defaults: ThumbprintOptions;
|
|
27
|
+
toBytes(tstring: string): Uint8Array<ArrayBuffer>;
|
|
28
|
+
parse(tstring: string, options?: Partial<ThumbprintOptions>): ThumbprintData;
|
|
29
|
+
build: {
|
|
30
|
+
fromBytes(raw: Uint8Array, options?: Partial<ThumbprintOptions>): ThumbprintData;
|
|
31
|
+
fromHex(hstring: string, options?: Partial<ThumbprintOptions>): ThumbprintData;
|
|
32
|
+
};
|
|
33
|
+
toHex(tstring: string): string;
|
|
34
|
+
fromBytes(b: Uint8Array, options?: Partial<ThumbprintOptions>): string;
|
|
35
|
+
fromHex(h: string, options?: Partial<ThumbprintOptions>): string;
|
|
36
|
+
sigil: {
|
|
37
|
+
fromHex(h: string, options?: Partial<ThumbprintOptions>): string;
|
|
38
|
+
fromBytes(b: Uint8Array, options?: Partial<ThumbprintOptions>): string;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
/** @deprecated renamed to `thumbprint` */
|
|
21
42
|
export declare const Thumbprint: {
|
|
22
43
|
defaults: ThumbprintOptions;
|
|
23
|
-
toBytes(
|
|
24
|
-
parse(
|
|
44
|
+
toBytes(tstring: string): Uint8Array<ArrayBuffer>;
|
|
45
|
+
parse(tstring: string, options?: Partial<ThumbprintOptions>): ThumbprintData;
|
|
25
46
|
build: {
|
|
26
|
-
fromBytes(
|
|
27
|
-
fromHex(
|
|
47
|
+
fromBytes(raw: Uint8Array, options?: Partial<ThumbprintOptions>): ThumbprintData;
|
|
48
|
+
fromHex(hstring: string, options?: Partial<ThumbprintOptions>): ThumbprintData;
|
|
28
49
|
};
|
|
29
|
-
toHex(
|
|
30
|
-
fromBytes(
|
|
31
|
-
fromHex(
|
|
50
|
+
toHex(tstring: string): string;
|
|
51
|
+
fromBytes(b: Uint8Array, options?: Partial<ThumbprintOptions>): string;
|
|
52
|
+
fromHex(h: string, options?: Partial<ThumbprintOptions>): string;
|
|
32
53
|
sigil: {
|
|
33
|
-
fromHex(
|
|
34
|
-
fromBytes(
|
|
54
|
+
fromHex(h: string, options?: Partial<ThumbprintOptions>): string;
|
|
55
|
+
fromBytes(b: Uint8Array, options?: Partial<ThumbprintOptions>): string;
|
|
35
56
|
};
|
|
36
57
|
};
|