@e280/stz 0.2.35 → 0.3.0-next.0
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/package.json +2 -2
- package/s/count.ts +0 -6
- package/s/cycle.ts +0 -3
- package/s/data/bytename/bytename.ts +0 -3
- package/s/data/bytename/thumbprint.ts +0 -12
- package/s/data/bytes.ts +0 -3
- package/s/data/txt.ts +0 -9
- package/s/index.ts +4 -11
- package/s/maybe/validators/validator.ts +0 -3
- package/s/ok/fns/get.ts +0 -3
- package/s/ok/fns/need.ts +0 -3
- package/s/time.ts +0 -3
- package/s/utensils/got.ts +6 -0
- package/s/utensils/map.ts +30 -0
- package/s/utensils/set.ts +19 -0
- package/x/count.d.ts +0 -4
- package/x/count.js +0 -4
- package/x/count.js.map +1 -1
- package/x/cycle.d.ts +0 -2
- package/x/cycle.js +0 -2
- package/x/cycle.js.map +1 -1
- package/x/data/bytename/bytename.d.ts +0 -9
- package/x/data/bytename/bytename.js +0 -2
- package/x/data/bytename/bytename.js.map +1 -1
- package/x/data/bytename/thumbprint.d.ts +0 -21
- package/x/data/bytename/thumbprint.js +0 -4
- package/x/data/bytename/thumbprint.js.map +1 -1
- package/x/data/bytes.d.ts +0 -5
- package/x/data/bytes.js +0 -2
- package/x/data/bytes.js.map +1 -1
- package/x/data/txt.d.ts +0 -4
- package/x/data/txt.js +0 -6
- package/x/data/txt.js.map +1 -1
- package/x/index.d.ts +3 -10
- package/x/index.js +3 -10
- package/x/index.js.map +1 -1
- package/x/maybe/validators/validator.d.ts +0 -2
- package/x/maybe/validators/validator.js +0 -2
- package/x/maybe/validators/validator.js.map +1 -1
- package/x/ok/fns/get.d.ts +0 -2
- package/x/ok/fns/get.js +0 -2
- package/x/ok/fns/get.js.map +1 -1
- package/x/ok/fns/need.d.ts +0 -2
- package/x/ok/fns/need.js +0 -2
- package/x/ok/fns/need.js.map +1 -1
- package/x/time.d.ts +0 -19
- package/x/time.js +0 -2
- package/x/time.js.map +1 -1
- package/x/utensils/got.d.ts +1 -0
- package/x/utensils/got.js +6 -0
- package/x/utensils/got.js.map +1 -0
- package/x/utensils/map.d.ts +9 -0
- package/x/utensils/map.js +21 -0
- package/x/utensils/map.js.map +1 -0
- package/x/utensils/set.d.ts +8 -0
- package/x/utensils/set.js +11 -0
- package/x/utensils/set.js.map +1 -0
- package/s/data/legacy/base58.ts +0 -76
- package/s/data/legacy/base64.ts +0 -32
- package/s/data/legacy/base64url.ts +0 -37
- package/s/data/legacy/hex.ts +0 -46
- package/s/drill.ts +0 -23
- package/s/g/map.ts +0 -49
- package/s/g/pool.ts +0 -24
- package/s/g/set.ts +0 -29
- package/s/g/weak-map.ts +0 -45
- package/s/hat.ts +0 -18
- package/x/data/legacy/base58.d.ts +0 -10
- package/x/data/legacy/base58.js +0 -67
- package/x/data/legacy/base58.js.map +0 -1
- package/x/data/legacy/base64.d.ts +0 -10
- package/x/data/legacy/base64.js +0 -26
- package/x/data/legacy/base64.js.map +0 -1
- package/x/data/legacy/base64url.d.ts +0 -10
- package/x/data/legacy/base64url.js +0 -31
- package/x/data/legacy/base64url.js.map +0 -1
- package/x/data/legacy/hex.d.ts +0 -11
- package/x/data/legacy/hex.js +0 -39
- package/x/data/legacy/hex.js.map +0 -1
- package/x/drill.d.ts +0 -7
- package/x/drill.js +0 -15
- package/x/drill.js.map +0 -1
- package/x/g/map.d.ts +0 -14
- package/x/g/map.js +0 -41
- package/x/g/map.js.map +0 -1
- package/x/g/pool.d.ts +0 -12
- package/x/g/pool.js +0 -17
- package/x/g/pool.js.map +0 -1
- package/x/g/set.d.ts +0 -9
- package/x/g/set.js +0 -25
- package/x/g/set.js.map +0 -1
- package/x/g/weak-map.d.ts +0 -13
- package/x/g/weak-map.js +0 -38
- package/x/g/weak-map.js.map +0 -1
- package/x/hat.d.ts +0 -7
- package/x/hat.js +0 -17
- package/x/hat.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function got<X>(thing: X | undefined | null): X;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"got.js","sourceRoot":"","sources":["../../s/utensils/got.ts"],"names":[],"mappings":"AACA,MAAM,UAAU,GAAG,CAAI,KAA2B;IACjD,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI;QAAE,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,CAAA;IACxE,OAAO,KAAK,CAAA;AACb,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
type MapLike<K, V> = {
|
|
2
|
+
has(key: K): boolean;
|
|
3
|
+
get(key: K): V | undefined;
|
|
4
|
+
set(key: K, value: V): unknown;
|
|
5
|
+
};
|
|
6
|
+
export declare function need<K, V>(map: MapLike<K, V>, key: K): V;
|
|
7
|
+
export declare function guarantee<K, V>(map: MapLike<K, V>, key: K, make: () => V): V;
|
|
8
|
+
export declare function inserts<K, V, M extends MapLike<K, V>>(map: M, entries: Iterable<[K, V]>): M;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export function need(map, key) {
|
|
2
|
+
if (map.has(key))
|
|
3
|
+
return map.get(key);
|
|
4
|
+
else
|
|
5
|
+
throw new Error("needed key not found");
|
|
6
|
+
}
|
|
7
|
+
export function guarantee(map, key, make) {
|
|
8
|
+
if (map.has(key))
|
|
9
|
+
return map.get(key);
|
|
10
|
+
else {
|
|
11
|
+
const value = make();
|
|
12
|
+
map.set(key, value);
|
|
13
|
+
return value;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
export function inserts(map, entries) {
|
|
17
|
+
for (const [key, value] of entries)
|
|
18
|
+
map.set(key, value);
|
|
19
|
+
return map;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=map.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"map.js","sourceRoot":"","sources":["../../s/utensils/map.ts"],"names":[],"mappings":"AAOA,MAAM,UAAU,IAAI,CAAO,GAAkB,EAAE,GAAM;IACpD,IAAI,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC;QACf,OAAO,GAAG,CAAC,GAAG,CAAC,GAAG,CAAM,CAAA;;QAExB,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAA;AACzC,CAAC;AAED,MAAM,UAAU,SAAS,CAAO,GAAkB,EAAE,GAAM,EAAE,IAAa;IACxE,IAAI,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC;QACf,OAAO,GAAG,CAAC,GAAG,CAAC,GAAG,CAAE,CAAA;SAChB,CAAC;QACL,MAAM,KAAK,GAAG,IAAI,EAAE,CAAA;QACpB,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;QACnB,OAAO,KAAK,CAAA;IACb,CAAC;AACF,CAAC;AAED,MAAM,UAAU,OAAO,CAAgC,GAAM,EAAE,OAAyB;IACvF,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,OAAO;QACjC,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;IACpB,OAAO,GAAG,CAAA;AACX,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
type SetLike<V> = {
|
|
2
|
+
has(value: V): boolean;
|
|
3
|
+
add(value: V): void;
|
|
4
|
+
delete(value: V): void;
|
|
5
|
+
};
|
|
6
|
+
export declare function adds<V, S extends SetLike<V>>(set: S, values: Iterable<V>): S;
|
|
7
|
+
export declare function deletes<V, S extends SetLike<V>>(set: S, values: Iterable<V>): S;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"set.js","sourceRoot":"","sources":["../../s/utensils/set.ts"],"names":[],"mappings":"AAOA,MAAM,UAAU,IAAI,CAA0B,GAAM,EAAE,MAAmB;IACxE,KAAK,MAAM,KAAK,IAAI,MAAM;QACzB,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;IACf,OAAO,GAAG,CAAA;AACX,CAAC;AAED,MAAM,UAAU,OAAO,CAA0B,GAAM,EAAE,MAAmB;IAC3E,KAAK,MAAM,KAAK,IAAI,MAAM;QACzB,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;IAClB,OAAO,GAAG,CAAA;AACX,CAAC"}
|
package/s/data/legacy/base58.ts
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
/*
|
|
3
|
-
|
|
4
|
-
256-bit base58 ids look like this:
|
|
5
|
-
|
|
6
|
-
9X1D9rdkDgRdykzmogNcxfopRc7TnbS869ow1E2ehCFS
|
|
7
|
-
AmRKyNfq6jhhsd9qda1Y6rAVS2NLUqyTUvfcB2wUiiAC
|
|
8
|
-
8skYcqBAXsejDcJzsZMo19PErt43DHP3bykaXBtMvdu
|
|
9
|
-
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
import {Hex} from "./hex.js"
|
|
13
|
-
import {bytes} from "../bytes.js"
|
|
14
|
-
|
|
15
|
-
const base = 58
|
|
16
|
-
const characters = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"
|
|
17
|
-
|
|
18
|
-
/** @deprecated use `base58` instead */
|
|
19
|
-
export const Base58 = Object.freeze({
|
|
20
|
-
fromBytes(bytes: Uint8Array) {
|
|
21
|
-
let intVal = BigInt("0x" + Hex.fromBytes(bytes))
|
|
22
|
-
let encoded = ""
|
|
23
|
-
|
|
24
|
-
while (intVal > 0) {
|
|
25
|
-
const remainder = intVal % BigInt(base)
|
|
26
|
-
intVal = intVal / BigInt(base)
|
|
27
|
-
encoded = characters[Number(remainder)] + encoded
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
for (const byte of bytes) {
|
|
31
|
-
if (byte === 0) encoded = characters[0] + encoded
|
|
32
|
-
else break
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
return encoded
|
|
36
|
-
},
|
|
37
|
-
|
|
38
|
-
toBytes(string: string) {
|
|
39
|
-
let intVal = BigInt(0)
|
|
40
|
-
|
|
41
|
-
for (const char of string) {
|
|
42
|
-
const index = characters.indexOf(char)
|
|
43
|
-
if (index === -1) throw new Error(`Invalid character '${char}' in base58 string`)
|
|
44
|
-
intVal = intVal * BigInt(base) + BigInt(index)
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
let hex = intVal.toString(16)
|
|
48
|
-
if (hex.length % 2 !== 0) hex = "0" + hex
|
|
49
|
-
const bytes = Hex.toBytes(hex)
|
|
50
|
-
|
|
51
|
-
let leadingZeroes = 0
|
|
52
|
-
for (const char of string) {
|
|
53
|
-
if (char === characters[0]) leadingZeroes++
|
|
54
|
-
else break
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
const decoded = new Uint8Array(leadingZeroes + bytes.length)
|
|
58
|
-
decoded.set(bytes, leadingZeroes)
|
|
59
|
-
return decoded
|
|
60
|
-
},
|
|
61
|
-
|
|
62
|
-
random(count = 32) {
|
|
63
|
-
return this.fromBytes(bytes.random(count))
|
|
64
|
-
},
|
|
65
|
-
|
|
66
|
-
/** @deprecated renamed to `fromBytes` */
|
|
67
|
-
string(bytes: Uint8Array) {
|
|
68
|
-
return Base58.fromBytes(bytes)
|
|
69
|
-
},
|
|
70
|
-
|
|
71
|
-
/** @deprecated renamed to `toBytes` */
|
|
72
|
-
bytes(string: string) {
|
|
73
|
-
return Base58.toBytes(string)
|
|
74
|
-
},
|
|
75
|
-
})
|
|
76
|
-
|
package/s/data/legacy/base64.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import {bytes} from "../bytes.js"
|
|
3
|
-
|
|
4
|
-
/** @deprecated use `base64` instead */
|
|
5
|
-
export const Base64 = Object.freeze({
|
|
6
|
-
fromBytes(bytes: Uint8Array) {
|
|
7
|
-
return (typeof btoa === "function")
|
|
8
|
-
? btoa(String.fromCharCode(...bytes))
|
|
9
|
-
: Buffer.from(bytes).toString("base64")
|
|
10
|
-
},
|
|
11
|
-
|
|
12
|
-
toBytes(string: string) {
|
|
13
|
-
return (typeof atob === "function")
|
|
14
|
-
? Uint8Array.from(atob(string), char => char.charCodeAt(0))
|
|
15
|
-
: Uint8Array.from(Buffer.from(string, "base64"))
|
|
16
|
-
},
|
|
17
|
-
|
|
18
|
-
random(count = 32) {
|
|
19
|
-
return this.fromBytes(bytes.random(count))
|
|
20
|
-
},
|
|
21
|
-
|
|
22
|
-
/** @deprecated rename to "fromBytes" */
|
|
23
|
-
string(bytes: Uint8Array) {
|
|
24
|
-
return Base64.fromBytes(bytes)
|
|
25
|
-
},
|
|
26
|
-
|
|
27
|
-
/** @deprecated rename to "toBytes" */
|
|
28
|
-
bytes(string: string) {
|
|
29
|
-
return Base64.toBytes(string)
|
|
30
|
-
},
|
|
31
|
-
})
|
|
32
|
-
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import {bytes} from "../bytes.js"
|
|
3
|
-
import {Base64} from "./base64.js"
|
|
4
|
-
|
|
5
|
-
/** @deprecated use `base64url` instead */
|
|
6
|
-
export const Base64url = {
|
|
7
|
-
fromBytes(bytes: Uint8Array) {
|
|
8
|
-
return Base64.fromBytes(bytes)
|
|
9
|
-
.replace(/\+/g, "-")
|
|
10
|
-
.replace(/\//g, "_")
|
|
11
|
-
.replace(/=+$/g, "")
|
|
12
|
-
},
|
|
13
|
-
|
|
14
|
-
toBytes(string: string) {
|
|
15
|
-
let b64 = string
|
|
16
|
-
.replace(/-/g, "+")
|
|
17
|
-
.replace(/_/g, "/")
|
|
18
|
-
if (b64.length % 4 !== 0)
|
|
19
|
-
b64 = b64.padEnd(b64.length + (4 - b64.length % 4) % 4, "=")
|
|
20
|
-
return Base64.toBytes(b64)
|
|
21
|
-
},
|
|
22
|
-
|
|
23
|
-
random(count = 32) {
|
|
24
|
-
return this.fromBytes(bytes.random(count))
|
|
25
|
-
},
|
|
26
|
-
|
|
27
|
-
/** @deprecated renamed to "fromBytes" */
|
|
28
|
-
string(bytes: Uint8Array) {
|
|
29
|
-
return Base64url.fromBytes(bytes)
|
|
30
|
-
},
|
|
31
|
-
|
|
32
|
-
/** @deprecated renamed to "toBytes" */
|
|
33
|
-
bytes(string: string) {
|
|
34
|
-
return Base64url.toBytes(string)
|
|
35
|
-
},
|
|
36
|
-
}
|
|
37
|
-
|
package/s/data/legacy/hex.ts
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
/*
|
|
3
|
-
|
|
4
|
-
256-bit hex ids look like this:
|
|
5
|
-
|
|
6
|
-
8ff8dfbc7c994c5439d2dd327b9898aa6796f97fb396e262985f03f868707e32
|
|
7
|
-
6b99284a2c4a1c5f101502bd009f9fb592ca4427e4375155e411ddd07ed9da6b
|
|
8
|
-
2eb73fb00a2b9e38c855b5aa353b530d820a3a2dcea5013b7e4e277ddfe9d0ad
|
|
9
|
-
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
import {bytes} from "../bytes.js"
|
|
13
|
-
|
|
14
|
-
/** @deprecated use `hex` instead */
|
|
15
|
-
export const Hex = Object.freeze({
|
|
16
|
-
fromBytes(bytes: Uint8Array) {
|
|
17
|
-
return [...bytes]
|
|
18
|
-
.map(byte => byte.toString(16).padStart(2, "0"))
|
|
19
|
-
.join("")
|
|
20
|
-
},
|
|
21
|
-
|
|
22
|
-
toBytes(string: string) {
|
|
23
|
-
if (string.length % 2 !== 0)
|
|
24
|
-
throw new Error("must have even number of hex characters")
|
|
25
|
-
const bytes = new Uint8Array(string.length / 2)
|
|
26
|
-
for (let i = 0; i < string.length; i += 2)
|
|
27
|
-
bytes[i / 2] = parseInt(string.slice(i, i + 2), 16)
|
|
28
|
-
return bytes
|
|
29
|
-
},
|
|
30
|
-
|
|
31
|
-
/** generate a random hex string. byteCount defaults to 32. */
|
|
32
|
-
random(byteCount = 32) {
|
|
33
|
-
return this.fromBytes(bytes.random(byteCount))
|
|
34
|
-
},
|
|
35
|
-
|
|
36
|
-
/** @deprecated renamed to `fromBytes` */
|
|
37
|
-
string(bytes: Uint8Array) {
|
|
38
|
-
return Hex.fromBytes(bytes)
|
|
39
|
-
},
|
|
40
|
-
|
|
41
|
-
/** @deprecated renamed to `toBytes` */
|
|
42
|
-
bytes(string: string) {
|
|
43
|
-
return Hex.toBytes(string)
|
|
44
|
-
},
|
|
45
|
-
})
|
|
46
|
-
|
package/s/drill.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import {is} from "./is.js"
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* return a value within an object tree, found at the given path.
|
|
6
|
-
* @deprecated prefer `dig` instead
|
|
7
|
-
*/
|
|
8
|
-
export function drill<xResult>(
|
|
9
|
-
object: {[key: string]: any},
|
|
10
|
-
path: string[],
|
|
11
|
-
): xResult {
|
|
12
|
-
|
|
13
|
-
let current: any = object
|
|
14
|
-
|
|
15
|
-
for (const key of path) {
|
|
16
|
-
current = current[key]
|
|
17
|
-
if (is.sad(current))
|
|
18
|
-
break
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
return current
|
|
22
|
-
}
|
|
23
|
-
|
package/s/g/map.ts
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
/** extended js map with handy methods like `require` and `guarantee` */
|
|
3
|
-
export class GMap<K, V> extends Map<K, V> {
|
|
4
|
-
static need<K, V>(map: Map<K, V>, key: K) {
|
|
5
|
-
if (map.has(key))
|
|
6
|
-
return map.get(key) as V
|
|
7
|
-
else
|
|
8
|
-
throw new Error(`needed key not found: "${key}"`)
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
static guarantee<K, V>(map: Map<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
|
-
array() {
|
|
22
|
-
return [...this]
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
need(key: K) {
|
|
26
|
-
return GMap.need(this, key)
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
guarantee(key: K, make: () => V) {
|
|
30
|
-
return GMap.guarantee(this, key, make)
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/** @deprecated renamed to `need` */
|
|
34
|
-
require(key: K) {
|
|
35
|
-
return GMap.require(this, key)
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/** @deprecated renamed to `need` */
|
|
39
|
-
static require<K, V>(map: Map<K, V>, key: K) {
|
|
40
|
-
if (map.has(key))
|
|
41
|
-
return map.get(key) as V
|
|
42
|
-
else
|
|
43
|
-
throw new Error(`required key not found: "${key}"`)
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/** @deprecated renamed to `GMap` */
|
|
48
|
-
export const MapG = GMap
|
|
49
|
-
|
package/s/g/pool.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import {GMap} from "./map.js"
|
|
3
|
-
|
|
4
|
-
export type Identifiable<Id = any> = {id: Id}
|
|
5
|
-
|
|
6
|
-
/** js map but for things that have an `id` field */
|
|
7
|
-
export class GPool<V extends Identifiable> extends GMap<V["id"], V> {
|
|
8
|
-
got(value: V) {
|
|
9
|
-
return this.has(value.id)
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
add(value: V) {
|
|
13
|
-
this.set(value.id, value)
|
|
14
|
-
return value
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
remove(value: V) {
|
|
18
|
-
return this.delete(value.id)
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/** @deprecated renamed to `GPool` */
|
|
23
|
-
export const PoolG = GPool
|
|
24
|
-
|
package/s/g/set.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
export class GSet<T> extends Set<T> {
|
|
3
|
-
array() {
|
|
4
|
-
return [...this]
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
hasAll(...items: T[]) {
|
|
8
|
-
return items.every(item => this.has(item))
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
adds(...items: T[]) {
|
|
12
|
-
for (const item of items) this.add(item)
|
|
13
|
-
return this
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
deletes(...items: T[]) {
|
|
17
|
-
for (const item of items) this.delete(item)
|
|
18
|
-
return this
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
clear() {
|
|
22
|
-
super.clear()
|
|
23
|
-
return this
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/** @deprecated renamed to `GSet` */
|
|
28
|
-
export const SetG = GSet
|
|
29
|
-
|
package/s/g/weak-map.ts
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
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 need<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(`needed 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
|
-
need(key: K) {
|
|
22
|
-
return GWeakMap.need(this, key)
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
guarantee(key: K, make: () => V) {
|
|
26
|
-
return GWeakMap.guarantee(this, key, make)
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/** @deprecated renamed to `need` */
|
|
30
|
-
require(key: K) {
|
|
31
|
-
return GWeakMap.require(this, key)
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/** @deprecated renamed to `need` */
|
|
35
|
-
static require<K extends WeakKey, V>(map: WeakMap<K, V>, key: K) {
|
|
36
|
-
if (map.has(key))
|
|
37
|
-
return map.get(key) as V
|
|
38
|
-
else
|
|
39
|
-
throw new Error(`required key not found`)
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/** @deprecated renamed to `GWeakMap` */
|
|
44
|
-
export const WeakMapG = GWeakMap
|
|
45
|
-
|
package/s/hat.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
/** @deprecated use `Dispenser` instead */
|
|
3
|
-
export class Hat<T> {
|
|
4
|
-
#content: T[] = []
|
|
5
|
-
|
|
6
|
-
constructor(public items: T[]) {
|
|
7
|
-
this.#content = [...items]
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
pull() {
|
|
11
|
-
if (this.#content.length === 0)
|
|
12
|
-
this.#content = [...this.items]
|
|
13
|
-
const index = Math.floor(Math.random() * this.#content.length)
|
|
14
|
-
const [item] = this.#content.splice(index, 1)
|
|
15
|
-
return item
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/** @deprecated use `base58` instead */
|
|
2
|
-
export declare const Base58: Readonly<{
|
|
3
|
-
fromBytes(bytes: Uint8Array): string;
|
|
4
|
-
toBytes(string: string): Uint8Array<ArrayBuffer>;
|
|
5
|
-
random(count?: number): string;
|
|
6
|
-
/** @deprecated renamed to `fromBytes` */
|
|
7
|
-
string(bytes: Uint8Array): string;
|
|
8
|
-
/** @deprecated renamed to `toBytes` */
|
|
9
|
-
bytes(string: string): Uint8Array<ArrayBuffer>;
|
|
10
|
-
}>;
|
package/x/data/legacy/base58.js
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
|
|
3
|
-
256-bit base58 ids look like this:
|
|
4
|
-
|
|
5
|
-
9X1D9rdkDgRdykzmogNcxfopRc7TnbS869ow1E2ehCFS
|
|
6
|
-
AmRKyNfq6jhhsd9qda1Y6rAVS2NLUqyTUvfcB2wUiiAC
|
|
7
|
-
8skYcqBAXsejDcJzsZMo19PErt43DHP3bykaXBtMvdu
|
|
8
|
-
|
|
9
|
-
*/
|
|
10
|
-
import { Hex } from "./hex.js";
|
|
11
|
-
import { bytes } from "../bytes.js";
|
|
12
|
-
const base = 58;
|
|
13
|
-
const characters = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
|
|
14
|
-
/** @deprecated use `base58` instead */
|
|
15
|
-
export const Base58 = Object.freeze({
|
|
16
|
-
fromBytes(bytes) {
|
|
17
|
-
let intVal = BigInt("0x" + Hex.fromBytes(bytes));
|
|
18
|
-
let encoded = "";
|
|
19
|
-
while (intVal > 0) {
|
|
20
|
-
const remainder = intVal % BigInt(base);
|
|
21
|
-
intVal = intVal / BigInt(base);
|
|
22
|
-
encoded = characters[Number(remainder)] + encoded;
|
|
23
|
-
}
|
|
24
|
-
for (const byte of bytes) {
|
|
25
|
-
if (byte === 0)
|
|
26
|
-
encoded = characters[0] + encoded;
|
|
27
|
-
else
|
|
28
|
-
break;
|
|
29
|
-
}
|
|
30
|
-
return encoded;
|
|
31
|
-
},
|
|
32
|
-
toBytes(string) {
|
|
33
|
-
let intVal = BigInt(0);
|
|
34
|
-
for (const char of string) {
|
|
35
|
-
const index = characters.indexOf(char);
|
|
36
|
-
if (index === -1)
|
|
37
|
-
throw new Error(`Invalid character '${char}' in base58 string`);
|
|
38
|
-
intVal = intVal * BigInt(base) + BigInt(index);
|
|
39
|
-
}
|
|
40
|
-
let hex = intVal.toString(16);
|
|
41
|
-
if (hex.length % 2 !== 0)
|
|
42
|
-
hex = "0" + hex;
|
|
43
|
-
const bytes = Hex.toBytes(hex);
|
|
44
|
-
let leadingZeroes = 0;
|
|
45
|
-
for (const char of string) {
|
|
46
|
-
if (char === characters[0])
|
|
47
|
-
leadingZeroes++;
|
|
48
|
-
else
|
|
49
|
-
break;
|
|
50
|
-
}
|
|
51
|
-
const decoded = new Uint8Array(leadingZeroes + bytes.length);
|
|
52
|
-
decoded.set(bytes, leadingZeroes);
|
|
53
|
-
return decoded;
|
|
54
|
-
},
|
|
55
|
-
random(count = 32) {
|
|
56
|
-
return this.fromBytes(bytes.random(count));
|
|
57
|
-
},
|
|
58
|
-
/** @deprecated renamed to `fromBytes` */
|
|
59
|
-
string(bytes) {
|
|
60
|
-
return Base58.fromBytes(bytes);
|
|
61
|
-
},
|
|
62
|
-
/** @deprecated renamed to `toBytes` */
|
|
63
|
-
bytes(string) {
|
|
64
|
-
return Base58.toBytes(string);
|
|
65
|
-
},
|
|
66
|
-
});
|
|
67
|
-
//# sourceMappingURL=base58.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"base58.js","sourceRoot":"","sources":["../../../s/data/legacy/base58.ts"],"names":[],"mappings":"AACA;;;;;;;;EAQE;AAEF,OAAO,EAAC,GAAG,EAAC,MAAM,UAAU,CAAA;AAC5B,OAAO,EAAC,KAAK,EAAC,MAAM,aAAa,CAAA;AAEjC,MAAM,IAAI,GAAG,EAAE,CAAA;AACf,MAAM,UAAU,GAAG,4DAA4D,CAAA;AAE/E,uCAAuC;AACvC,MAAM,CAAC,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;IACnC,SAAS,CAAC,KAAiB;QAC1B,IAAI,MAAM,GAAG,MAAM,CAAC,IAAI,GAAG,GAAG,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAA;QAChD,IAAI,OAAO,GAAG,EAAE,CAAA;QAEhB,OAAO,MAAM,GAAG,CAAC,EAAE,CAAC;YACnB,MAAM,SAAS,GAAG,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,CAAA;YACvC,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,CAAA;YAC9B,OAAO,GAAG,UAAU,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,GAAG,OAAO,CAAA;QAClD,CAAC;QAED,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YAC1B,IAAI,IAAI,KAAK,CAAC;gBAAE,OAAO,GAAG,UAAU,CAAC,CAAC,CAAC,GAAG,OAAO,CAAA;;gBAC5C,MAAK;QACX,CAAC;QAED,OAAO,OAAO,CAAA;IACf,CAAC;IAED,OAAO,CAAC,MAAc;QACrB,IAAI,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,CAAA;QAEtB,KAAK,MAAM,IAAI,IAAI,MAAM,EAAE,CAAC;YAC3B,MAAM,KAAK,GAAG,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;YACtC,IAAI,KAAK,KAAK,CAAC,CAAC;gBAAE,MAAM,IAAI,KAAK,CAAC,sBAAsB,IAAI,oBAAoB,CAAC,CAAA;YACjF,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,CAAA;QAC/C,CAAC;QAED,IAAI,GAAG,GAAG,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAA;QAC7B,IAAI,GAAG,CAAC,MAAM,GAAG,CAAC,KAAK,CAAC;YAAE,GAAG,GAAG,GAAG,GAAG,GAAG,CAAA;QACzC,MAAM,KAAK,GAAG,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;QAE9B,IAAI,aAAa,GAAG,CAAC,CAAA;QACrB,KAAK,MAAM,IAAI,IAAI,MAAM,EAAE,CAAC;YAC3B,IAAI,IAAI,KAAK,UAAU,CAAC,CAAC,CAAC;gBAAE,aAAa,EAAE,CAAA;;gBACtC,MAAK;QACX,CAAC;QAED,MAAM,OAAO,GAAG,IAAI,UAAU,CAAC,aAAa,GAAG,KAAK,CAAC,MAAM,CAAC,CAAA;QAC5D,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,aAAa,CAAC,CAAA;QACjC,OAAO,OAAO,CAAA;IACf,CAAC;IAED,MAAM,CAAC,KAAK,GAAG,EAAE;QAChB,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAA;IAC3C,CAAC;IAED,yCAAyC;IACzC,MAAM,CAAC,KAAiB;QACvB,OAAO,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAA;IAC/B,CAAC;IAED,uCAAuC;IACvC,KAAK,CAAC,MAAc;QACnB,OAAO,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;IAC9B,CAAC;CACD,CAAC,CAAA"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/** @deprecated use `base64` instead */
|
|
2
|
-
export declare const Base64: Readonly<{
|
|
3
|
-
fromBytes(bytes: Uint8Array): string;
|
|
4
|
-
toBytes(string: string): Uint8Array<ArrayBuffer>;
|
|
5
|
-
random(count?: number): string;
|
|
6
|
-
/** @deprecated rename to "fromBytes" */
|
|
7
|
-
string(bytes: Uint8Array): string;
|
|
8
|
-
/** @deprecated rename to "toBytes" */
|
|
9
|
-
bytes(string: string): Uint8Array<ArrayBuffer>;
|
|
10
|
-
}>;
|
package/x/data/legacy/base64.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { bytes } from "../bytes.js";
|
|
2
|
-
/** @deprecated use `base64` instead */
|
|
3
|
-
export const Base64 = Object.freeze({
|
|
4
|
-
fromBytes(bytes) {
|
|
5
|
-
return (typeof btoa === "function")
|
|
6
|
-
? btoa(String.fromCharCode(...bytes))
|
|
7
|
-
: Buffer.from(bytes).toString("base64");
|
|
8
|
-
},
|
|
9
|
-
toBytes(string) {
|
|
10
|
-
return (typeof atob === "function")
|
|
11
|
-
? Uint8Array.from(atob(string), char => char.charCodeAt(0))
|
|
12
|
-
: Uint8Array.from(Buffer.from(string, "base64"));
|
|
13
|
-
},
|
|
14
|
-
random(count = 32) {
|
|
15
|
-
return this.fromBytes(bytes.random(count));
|
|
16
|
-
},
|
|
17
|
-
/** @deprecated rename to "fromBytes" */
|
|
18
|
-
string(bytes) {
|
|
19
|
-
return Base64.fromBytes(bytes);
|
|
20
|
-
},
|
|
21
|
-
/** @deprecated rename to "toBytes" */
|
|
22
|
-
bytes(string) {
|
|
23
|
-
return Base64.toBytes(string);
|
|
24
|
-
},
|
|
25
|
-
});
|
|
26
|
-
//# sourceMappingURL=base64.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"base64.js","sourceRoot":"","sources":["../../../s/data/legacy/base64.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,KAAK,EAAC,MAAM,aAAa,CAAA;AAEjC,uCAAuC;AACvC,MAAM,CAAC,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;IACnC,SAAS,CAAC,KAAiB;QAC1B,OAAO,CAAC,OAAO,IAAI,KAAK,UAAU,CAAC;YAClC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,GAAG,KAAK,CAAC,CAAC;YACrC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAA;IACzC,CAAC;IAED,OAAO,CAAC,MAAc;QACrB,OAAO,CAAC,OAAO,IAAI,KAAK,UAAU,CAAC;YAClC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;YAC3D,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAA;IAClD,CAAC;IAED,MAAM,CAAC,KAAK,GAAG,EAAE;QAChB,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAA;IAC3C,CAAC;IAED,wCAAwC;IACxC,MAAM,CAAC,KAAiB;QACvB,OAAO,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAA;IAC/B,CAAC;IAED,sCAAsC;IACtC,KAAK,CAAC,MAAc;QACnB,OAAO,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;IAC9B,CAAC;CACD,CAAC,CAAA"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/** @deprecated use `base64url` instead */
|
|
2
|
-
export declare const Base64url: {
|
|
3
|
-
fromBytes(bytes: Uint8Array): string;
|
|
4
|
-
toBytes(string: string): Uint8Array<ArrayBuffer>;
|
|
5
|
-
random(count?: number): string;
|
|
6
|
-
/** @deprecated renamed to "fromBytes" */
|
|
7
|
-
string(bytes: Uint8Array): string;
|
|
8
|
-
/** @deprecated renamed to "toBytes" */
|
|
9
|
-
bytes(string: string): Uint8Array<ArrayBuffer>;
|
|
10
|
-
};
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { bytes } from "../bytes.js";
|
|
2
|
-
import { Base64 } from "./base64.js";
|
|
3
|
-
/** @deprecated use `base64url` instead */
|
|
4
|
-
export const Base64url = {
|
|
5
|
-
fromBytes(bytes) {
|
|
6
|
-
return Base64.fromBytes(bytes)
|
|
7
|
-
.replace(/\+/g, "-")
|
|
8
|
-
.replace(/\//g, "_")
|
|
9
|
-
.replace(/=+$/g, "");
|
|
10
|
-
},
|
|
11
|
-
toBytes(string) {
|
|
12
|
-
let b64 = string
|
|
13
|
-
.replace(/-/g, "+")
|
|
14
|
-
.replace(/_/g, "/");
|
|
15
|
-
if (b64.length % 4 !== 0)
|
|
16
|
-
b64 = b64.padEnd(b64.length + (4 - b64.length % 4) % 4, "=");
|
|
17
|
-
return Base64.toBytes(b64);
|
|
18
|
-
},
|
|
19
|
-
random(count = 32) {
|
|
20
|
-
return this.fromBytes(bytes.random(count));
|
|
21
|
-
},
|
|
22
|
-
/** @deprecated renamed to "fromBytes" */
|
|
23
|
-
string(bytes) {
|
|
24
|
-
return Base64url.fromBytes(bytes);
|
|
25
|
-
},
|
|
26
|
-
/** @deprecated renamed to "toBytes" */
|
|
27
|
-
bytes(string) {
|
|
28
|
-
return Base64url.toBytes(string);
|
|
29
|
-
},
|
|
30
|
-
};
|
|
31
|
-
//# sourceMappingURL=base64url.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"base64url.js","sourceRoot":"","sources":["../../../s/data/legacy/base64url.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,KAAK,EAAC,MAAM,aAAa,CAAA;AACjC,OAAO,EAAC,MAAM,EAAC,MAAM,aAAa,CAAA;AAElC,0CAA0C;AAC1C,MAAM,CAAC,MAAM,SAAS,GAAG;IACxB,SAAS,CAAC,KAAiB;QAC1B,OAAO,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC;aAC5B,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC;aACnB,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC;aACnB,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAA;IACtB,CAAC;IAED,OAAO,CAAC,MAAc;QACrB,IAAI,GAAG,GAAG,MAAM;aACd,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC;aAClB,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAA;QACpB,IAAI,GAAG,CAAC,MAAM,GAAG,CAAC,KAAK,CAAC;YACvB,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,CAAA;QAC7D,OAAO,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;IAC3B,CAAC;IAED,MAAM,CAAC,KAAK,GAAG,EAAE;QAChB,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAA;IAC3C,CAAC;IAED,yCAAyC;IACzC,MAAM,CAAC,KAAiB;QACvB,OAAO,SAAS,CAAC,SAAS,CAAC,KAAK,CAAC,CAAA;IAClC,CAAC;IAED,uCAAuC;IACvC,KAAK,CAAC,MAAc;QACnB,OAAO,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;IACjC,CAAC;CACD,CAAA"}
|
package/x/data/legacy/hex.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/** @deprecated use `hex` instead */
|
|
2
|
-
export declare const Hex: Readonly<{
|
|
3
|
-
fromBytes(bytes: Uint8Array): string;
|
|
4
|
-
toBytes(string: string): Uint8Array<ArrayBuffer>;
|
|
5
|
-
/** generate a random hex string. byteCount defaults to 32. */
|
|
6
|
-
random(byteCount?: number): string;
|
|
7
|
-
/** @deprecated renamed to `fromBytes` */
|
|
8
|
-
string(bytes: Uint8Array): string;
|
|
9
|
-
/** @deprecated renamed to `toBytes` */
|
|
10
|
-
bytes(string: string): Uint8Array<ArrayBuffer>;
|
|
11
|
-
}>;
|