@agoric/internal 0.3.3-dev-5b02250.0 → 0.3.3-dev-a4a571e.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 +3 -3
- package/src/testing-utils.d.ts +2 -0
- package/src/testing-utils.d.ts.map +1 -1
- package/src/testing-utils.js +37 -0
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-a4a571e.0+a4a571e",
|
|
4
4
|
"description": "Externally unsupported utilities internal to agoric-sdk",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"lint:types": "tsc"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@agoric/base-zone": "0.1.1-dev-
|
|
23
|
+
"@agoric/base-zone": "0.1.1-dev-a4a571e.0+a4a571e",
|
|
24
24
|
"@endo/common": "^1.2.2",
|
|
25
25
|
"@endo/errors": "^1.2.2",
|
|
26
26
|
"@endo/far": "^1.1.2",
|
|
@@ -58,5 +58,5 @@
|
|
|
58
58
|
"typeCoverage": {
|
|
59
59
|
"atLeast": 93.89
|
|
60
60
|
},
|
|
61
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "a4a571ef63fbbed00cf76d946f2bc90c65abfac1"
|
|
62
62
|
}
|
package/src/testing-utils.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testing-utils.d.ts","sourceRoot":"","sources":["testing-utils.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"testing-utils.d.ts","sourceRoot":"","sources":["testing-utils.js"],"names":[],"mappings":"AAeO,mDACwC;AAgBxC,uCAHI,QAAQ,GACN,MAAM,CAqBlB;8BA7C2B,eAAe"}
|
package/src/testing-utils.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
// @ts-check
|
|
1
2
|
/**
|
|
2
3
|
* @file note this cannot be called test-utils.js due to
|
|
3
4
|
* https://github.com/Agoric/agoric-sdk/issues/7503
|
|
4
5
|
*/
|
|
5
6
|
/* global setImmediate */
|
|
7
|
+
/** @import {MapStore} from '@agoric/store'; */
|
|
6
8
|
|
|
7
9
|
/**
|
|
8
10
|
* A workaround for some issues with fake time in tests.
|
|
@@ -14,3 +16,38 @@
|
|
|
14
16
|
export const eventLoopIteration = async () =>
|
|
15
17
|
new Promise(resolve => setImmediate(resolve));
|
|
16
18
|
harden(eventLoopIteration);
|
|
19
|
+
|
|
20
|
+
/** @type {(value: any) => string} */
|
|
21
|
+
const stringOrTag = value => {
|
|
22
|
+
if (typeof value === 'string') {
|
|
23
|
+
return value;
|
|
24
|
+
} else if (typeof value === 'object' && Symbol.toStringTag in value) {
|
|
25
|
+
return value[Symbol.toStringTag];
|
|
26
|
+
}
|
|
27
|
+
return String(value);
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* @param {MapStore} store
|
|
31
|
+
* @returns {object} tree of the contents of the storeÂ
|
|
32
|
+
*/
|
|
33
|
+
export const inspectMapStore = store => {
|
|
34
|
+
/** @type {Record<string, unknown>} */
|
|
35
|
+
const obj = {};
|
|
36
|
+
for (const key of store.keys()) {
|
|
37
|
+
const value = store.get(key);
|
|
38
|
+
const hasKeys = typeof value === 'object' && 'keys' in value;
|
|
39
|
+
const index = stringOrTag(key);
|
|
40
|
+
if (hasKeys && 'get' in value) {
|
|
41
|
+
obj[index] = inspectMapStore(value);
|
|
42
|
+
} else if (hasKeys) {
|
|
43
|
+
obj[index] = Array.from(value.keys());
|
|
44
|
+
} else {
|
|
45
|
+
obj[index] =
|
|
46
|
+
value instanceof Object && Symbol.toStringTag in value
|
|
47
|
+
? value[Symbol.toStringTag]
|
|
48
|
+
: value;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return obj;
|
|
52
|
+
};
|
|
53
|
+
harden(inspectMapStore);
|