@agoric/internal 0.3.3-dev-6169838.0.6169838 → 0.3.3-dev-98e20a0.0.98e20a0
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 +4 -4
- package/src/hex.d.ts.map +1 -1
- package/src/hex.js +7 -8
- package/src/js-utils.d.ts +14 -0
- package/src/js-utils.d.ts.map +1 -1
- package/src/js-utils.js +19 -0
- package/src/marshal/wrap-marshaller.js +4 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agoric/internal",
|
|
3
|
-
"version": "0.3.3-dev-
|
|
3
|
+
"version": "0.3.3-dev-98e20a0.0.98e20a0",
|
|
4
4
|
"description": "Externally unsupported utilities internal to agoric-sdk",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"lint:types": "yarn run -T tsgo --tsBuildInfoFile tsconfig.tsgo.tsbuildinfo"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@agoric/base-zone": "0.1.1-dev-
|
|
27
|
+
"@agoric/base-zone": "0.1.1-dev-98e20a0.0.98e20a0",
|
|
28
28
|
"@endo/cache-map": "^1.1.0",
|
|
29
29
|
"@endo/common": "^1.4.0",
|
|
30
30
|
"@endo/compartment-mapper": "^2.3.0",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"jessie.js": "^0.3.4"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@agoric/cosmic-proto": "0.4.1-dev-
|
|
45
|
+
"@agoric/cosmic-proto": "0.4.1-dev-98e20a0.0.98e20a0",
|
|
46
46
|
"@endo/exo": "^1.7.0",
|
|
47
47
|
"@endo/init": "^1.1.13",
|
|
48
48
|
"@endo/ses-ava": "^1.4.2",
|
|
@@ -62,5 +62,5 @@
|
|
|
62
62
|
"typeCoverage": {
|
|
63
63
|
"atLeast": 95.63
|
|
64
64
|
},
|
|
65
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "98e20a0ea189c7d4a12193a29dccff170e0032a3"
|
|
66
66
|
}
|
package/src/hex.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hex.d.ts","sourceRoot":"","sources":["hex.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"hex.d.ts","sourceRoot":"","sources":["hex.js"],"names":[],"mappings":"AAkCO,wCAFM,QAAQ,CAyBpB;AAgBM,iDAJI,oBAAoB,GAElB,QAAQ,CAoBpB;8BAzFmB,UAAU,KAAK,MAAM;8BACrB,MAAM,KAAK,UAAU;;eAD3B,CAAC,GAAG,EAAE,UAAU,KAAK,MAAM;eAC3B,CAAC,GAAG,EAAE,MAAM,KAAK,UAAU;;;;;mCAyD5B,IAAI,CAAC,iBAAiB,EAAE,MAAM,GAAG,UAAU,CAAC,GAAG;IACvD,SAAS,EAAE,IAAI,CAAC,MAAM,EAAE,UAAU,CAAC,GAAG,UAAU,CAAC;CAClD"}
|
package/src/hex.js
CHANGED
|
@@ -5,13 +5,10 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
/** @type {string[]} */
|
|
8
|
-
const encodings = Array
|
|
9
|
-
// Write the hex representation of the byte.
|
|
10
|
-
b.toString(16).padStart(2, '0'),
|
|
11
|
-
);
|
|
8
|
+
const encodings = new Array(256);
|
|
12
9
|
|
|
13
10
|
/**
|
|
14
|
-
*
|
|
11
|
+
* Map entries for all four permutations of lowercase and uppercase
|
|
15
12
|
* transformations of the two hex digits per byte. The map is keyed by the hex
|
|
16
13
|
* string and the value is the byte value. This allows for fast lookups when
|
|
17
14
|
* decoding hex strings.
|
|
@@ -19,9 +16,11 @@ const encodings = Array.from({ length: 256 }, (_, b) =>
|
|
|
19
16
|
* @type {Map<string, number>}
|
|
20
17
|
*/
|
|
21
18
|
const decodings = new Map();
|
|
22
|
-
for (
|
|
23
|
-
|
|
24
|
-
const
|
|
19
|
+
for (let b = 0; b < 256; b += 1) {
|
|
20
|
+
// Write the hex representation of the byte.
|
|
21
|
+
const lo = b.toString(16).padStart(2, '0');
|
|
22
|
+
const UP = lo.toUpperCase();
|
|
23
|
+
encodings[b] = lo;
|
|
25
24
|
decodings.set(lo, b);
|
|
26
25
|
decodings.set(`${lo[0]}${UP[1]}`, b);
|
|
27
26
|
decodings.set(`${UP[0]}${lo[1]}`, b);
|
package/src/js-utils.d.ts
CHANGED
|
@@ -25,6 +25,20 @@ export const fromTypedEntries: FromTypedEntries;
|
|
|
25
25
|
*/
|
|
26
26
|
export const typedMap: TypedMap;
|
|
27
27
|
export const logLevels: readonly ["debug", "log", "info", "warn", "error"];
|
|
28
|
+
/** @typedef {(typeof logLevels)[keyof typeof logLevels & number]} LogLevel */
|
|
29
|
+
/** @typedef {Pick<Console, LogLevel>} LimitedConsole */
|
|
30
|
+
/**
|
|
31
|
+
* Compare two same-type values using built-in operators.
|
|
32
|
+
* All zeros are placed in an equivalence class that ignores their sign, all
|
|
33
|
+
* NaNs are placed in an equivalence class after all other numbers, and strings
|
|
34
|
+
* are compared lexicographically by UTF-16 code unit.
|
|
35
|
+
*
|
|
36
|
+
* @type {((a: bigint, b: bigint) => -1 | 0 | 1) &
|
|
37
|
+
* ((a: number, b: number) => -1 | 0 | 1) &
|
|
38
|
+
* ((a: string, b: string) => -1 | 0 | 1)
|
|
39
|
+
* }
|
|
40
|
+
*/
|
|
41
|
+
export const naiveCompare: ((a: bigint, b: bigint) => -1 | 0 | 1) & ((a: number, b: number) => -1 | 0 | 1) & ((a: string, b: string) => -1 | 0 | 1);
|
|
28
42
|
export function deepCopyJsonable<T>(value: T): T;
|
|
29
43
|
export function deepMapObject<O extends Record<string, unknown>, M>(obj: O, mapper: <T extends Record<string, unknown>, K extends string & keyof T>(value: T[K], name: K, record: T) => T[K] | M): O | { [K_1 in keyof O]: K_1 extends string ? O[K_1] | M : never; };
|
|
30
44
|
export function defineName<F extends Function>(name: string, fn: F): F;
|
package/src/js-utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"js-utils.d.ts","sourceRoot":"","sources":["js-utils.js"],"names":[],"mappings":"AAQA,yEAAyE;AACzE,mBAA0C,IAAI,CAAE;AAEhD;;;;;;;GAOG;AACH,2BAAuC,YAAY,CAAsB;AAEzE;;;;;;GAMG;AACH,+BAA2C,gBAAgB,CAEzD;AAEF;;;;;GAKG;AACH,uBAAmC,QAAQ,CAEzC;AAEF,2EAMG;
|
|
1
|
+
{"version":3,"file":"js-utils.d.ts","sourceRoot":"","sources":["js-utils.js"],"names":[],"mappings":"AAQA,yEAAyE;AACzE,mBAA0C,IAAI,CAAE;AAEhD;;;;;;;GAOG;AACH,2BAAuC,YAAY,CAAsB;AAEzE;;;;;;GAMG;AACH,+BAA2C,gBAAgB,CAEzD;AAEF;;;;;GAKG;AACH,uBAAmC,QAAQ,CAEzC;AAEF,2EAMG;AAGH,8EAA8E;AAE9E,wDAAwD;AAExD;;;;;;;;;;GAUG;AACH,2BALU,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAC/C,CAAK,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAC1C,CAAK,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CASzC;AAWK,iCAJM,CAAC,SACH,CAAC,GACC,CAAC,CAE4D;AAsEnE,8BAVgC,CAAC,SAA1B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAE,EACzB,CAAC,OACH,CAAC,UACD,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC,SAAS,MAAM,GAAG,MAAM,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AaM,qCANe,CAAC,SAAV,MAAQ,EACC,CAAC,SAAV,MAAQ,EACR,CAAC,OACH,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC,UACrB,CAAC,GAGC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAMtB;2BAxQU,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC1C,GAAG,EAAE,CAAC,KACH,OAAO,CACd,GAAO,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,SAAS,MAAM,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,GAAE,CAAC,MAAM,CAAC,CAAC,EACrE,SAAa,CACV,EAAE;+BAKO,CACZ,KAAS,CAAC,OAAO,SAAS,aAAa,CAAC,SAAS,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC,EAEpE,OAAO,EAAE,OAAO,KACb,GAAG,KAAK,IAAI,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,GAAE;uBAO/C,CAAC,CAAC,SAAS,OAAO,EAAE,EAAE,CAAC,EAC/B,GAAG,EAAE,CAAC,EACN,MAAM,EAAE,CAAC,CAAC,SAAS,MAAM,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,KACtD,CAAC,EAAE;uBAeG,CAAC,OAAO,SAAS,EAAE,MAAM,OAAO,SAAS,GAAG,MAAM,CAAC;6BAEnD,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC"}
|
package/src/js-utils.js
CHANGED
|
@@ -53,6 +53,25 @@ Object.freeze(logLevels);
|
|
|
53
53
|
|
|
54
54
|
/** @typedef {Pick<Console, LogLevel>} LimitedConsole */
|
|
55
55
|
|
|
56
|
+
/**
|
|
57
|
+
* Compare two same-type values using built-in operators.
|
|
58
|
+
* All zeros are placed in an equivalence class that ignores their sign, all
|
|
59
|
+
* NaNs are placed in an equivalence class after all other numbers, and strings
|
|
60
|
+
* are compared lexicographically by UTF-16 code unit.
|
|
61
|
+
*
|
|
62
|
+
* @type {((a: bigint, b: bigint) => -1 | 0 | 1) &
|
|
63
|
+
* ((a: number, b: number) => -1 | 0 | 1) &
|
|
64
|
+
* ((a: string, b: string) => -1 | 0 | 1)
|
|
65
|
+
* }
|
|
66
|
+
*/
|
|
67
|
+
export const naiveCompare = (a, b) => {
|
|
68
|
+
if (a < b) return -1;
|
|
69
|
+
if (a > b) return 1;
|
|
70
|
+
return /** @type {-1 | 0 | 1} */ (
|
|
71
|
+
(Number.isNaN(a) ? 1 : 0) - (Number.isNaN(b) ? 1 : 0)
|
|
72
|
+
);
|
|
73
|
+
};
|
|
74
|
+
|
|
56
75
|
/**
|
|
57
76
|
* Deep-copy a value by round-tripping it through JSON (which drops
|
|
58
77
|
* function/symbol/undefined values and properties that are non-enumerable
|
|
@@ -200,9 +200,9 @@ export const wrapRemoteMarshallerSendSlotsOnly = (
|
|
|
200
200
|
let hasRemoteCap = false;
|
|
201
201
|
const { length } = slots;
|
|
202
202
|
/** @type {(RemotableSlotWrapper<NonNullable<Slot>> | null | undefined)[]} */
|
|
203
|
-
const slotWrapperMappedSlots = Array
|
|
203
|
+
const slotWrapperMappedSlots = new Array(length).fill(undefined);
|
|
204
204
|
/** @type {(object | null | undefined)[]} */
|
|
205
|
-
const locallyResolvedCapSlots = Array
|
|
205
|
+
const locallyResolvedCapSlots = new Array(length).fill(undefined);
|
|
206
206
|
|
|
207
207
|
for (const [index, slot] of slots.entries()) {
|
|
208
208
|
if (slot === null) {
|
|
@@ -268,9 +268,9 @@ export const wrapRemoteMarshallerSendSlotsOnly = (
|
|
|
268
268
|
let hasRemoteCap = false;
|
|
269
269
|
const { length } = caps;
|
|
270
270
|
/** @type {(Slot | null | undefined)[]} */
|
|
271
|
-
const locallyResolvedSlots = Array
|
|
271
|
+
const locallyResolvedSlots = new Array(length).fill(undefined);
|
|
272
272
|
/** @type {(object | null | undefined)[]} */
|
|
273
|
-
const remoteCapsToResolve = Array
|
|
273
|
+
const remoteCapsToResolve = new Array(length).fill(undefined);
|
|
274
274
|
|
|
275
275
|
for (const [index, cap] of caps.entries()) {
|
|
276
276
|
if (cap === null) {
|