@agoric/internal 0.2.2-dev-0534694.0 → 0.2.2-dev-724fbe0.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 +4 -2
- package/src/config.d.ts +12 -0
- package/src/config.d.ts.map +1 -0
- package/src/index.d.ts +3 -0
- package/src/index.d.ts.map +1 -0
- package/src/utils.d.ts +48 -0
- package/src/utils.d.ts.map +1 -0
- package/src/utils.js +18 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agoric/internal",
|
|
3
|
-
"version": "0.2.2-dev-
|
|
3
|
+
"version": "0.2.2-dev-724fbe0.0+724fbe0",
|
|
4
4
|
"description": "Externally unsupported utilities internal to agoric-sdk",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -9,6 +9,8 @@
|
|
|
9
9
|
},
|
|
10
10
|
"scripts": {
|
|
11
11
|
"build": "exit 0",
|
|
12
|
+
"prepack": "tsc --build jsconfig.build.json",
|
|
13
|
+
"postpack": "git clean -f '*.d.ts*'",
|
|
12
14
|
"test": "ava",
|
|
13
15
|
"test:nyc": "exit 0",
|
|
14
16
|
"test:xs": "exit 0",
|
|
@@ -34,5 +36,5 @@
|
|
|
34
36
|
"publishConfig": {
|
|
35
37
|
"access": "public"
|
|
36
38
|
},
|
|
37
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "724fbe0a01516b39ef1e3b4946211a70ac0aa42d"
|
|
38
40
|
}
|
package/src/config.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export namespace BridgeId {
|
|
2
|
+
const BANK: string;
|
|
3
|
+
const CORE: string;
|
|
4
|
+
const DIBC: string;
|
|
5
|
+
const STORAGE: string;
|
|
6
|
+
const PROVISION: string;
|
|
7
|
+
const WALLET: string;
|
|
8
|
+
}
|
|
9
|
+
export namespace WalletName {
|
|
10
|
+
const depositFacet: string;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["config.js"],"names":[],"mappings":""}
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.js"],"names":[],"mappings":""}
|
package/src/utils.d.ts
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export function fromUniqueEntries<K, V>(allEntries: Iterable<[K, V]>): {};
|
|
2
|
+
export function objectMap<O extends Record<string, any>, R>(original: O, mapFn: (value: O[keyof O], key: keyof O) => R): { [P in keyof O]: R; };
|
|
3
|
+
export function listDifference(leftNames: Array<string | symbol>, rightNames: Array<string | symbol>): (string | symbol)[];
|
|
4
|
+
export function throwLabeled(innerErr: Error, label: string | number, ErrorConstructor?: ErrorConstructor | undefined): never;
|
|
5
|
+
export function applyLabelingError<A, R>(func: (...args: A[]) => R, args: A[], label?: string | number | undefined): R;
|
|
6
|
+
export function getMethodNames(obj: Record<string | symbol, unknown>): (string | symbol)[];
|
|
7
|
+
export function bindAllMethods(obj: Remotable): Remotable;
|
|
8
|
+
/**
|
|
9
|
+
* @template {{}} T
|
|
10
|
+
* @typedef {{ [K in keyof T]: DeeplyAwaited<T[K]> }} DeeplyAwaitedObject
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Caveats:
|
|
14
|
+
* - doesn't recur within Promise results
|
|
15
|
+
* - resulting type has wrapper in its name
|
|
16
|
+
*
|
|
17
|
+
* @template T
|
|
18
|
+
* @typedef {T extends PromiseLike<any> ? Awaited<T> : T extends {} ? DeeplyAwaitedObject<T> : Awaited<T>} DeeplyAwaited
|
|
19
|
+
*/
|
|
20
|
+
/**
|
|
21
|
+
* A more constrained version of {deeplyFulfilled} for type safety until https://github.com/endojs/endo/issues/1257
|
|
22
|
+
* Useful in starting contracts that need all terms to be fulfilled in order to be durable.
|
|
23
|
+
*
|
|
24
|
+
* @type {<T extends {}>(unfulfilledTerms: T) => import('@endo/eventual-send').ERef<DeeplyAwaited<T>>}
|
|
25
|
+
*/
|
|
26
|
+
export const deeplyFulfilledObject: <T extends {}>(unfulfilledTerms: T) => import("@endo/eventual-send").ERef<DeeplyAwaited<T>>;
|
|
27
|
+
export function makeMeasureSeconds(currentTimeMillisec: typeof import('perf_hooks').performance.now): <T>(fn: () => Promise<T>) => Promise<{
|
|
28
|
+
result: T;
|
|
29
|
+
duration: number;
|
|
30
|
+
}>;
|
|
31
|
+
export function makeAggregateError(errors: Error[], message?: string | undefined): Error;
|
|
32
|
+
export function PromiseAllOrErrors<T>(values: readonly (T | PromiseLike<T>)[]): Promise<T[]>;
|
|
33
|
+
/**
|
|
34
|
+
* @type {<T>(
|
|
35
|
+
* trier: () => Promise<T>,
|
|
36
|
+
* finalizer: (error?: unknown) => Promise<void>,
|
|
37
|
+
* ) => Promise<T>}
|
|
38
|
+
*/ export const aggregateTryFinally: <T>(trier: () => Promise<T>, finalizer: (error?: unknown) => Promise<void>) => Promise<T>;
|
|
39
|
+
export function fsStreamReady(stream: import("fs").ReadStream | import("fs").WriteStream): Promise<void>;
|
|
40
|
+
export type Remotable = import('@endo/marshal/src/types').Remotable;
|
|
41
|
+
export type DeeplyAwaitedObject<T extends {}> = { [K in keyof T]: DeeplyAwaited<T[K]>; };
|
|
42
|
+
/**
|
|
43
|
+
* Caveats:
|
|
44
|
+
* - doesn't recur within Promise results
|
|
45
|
+
* - resulting type has wrapper in its name
|
|
46
|
+
*/
|
|
47
|
+
export type DeeplyAwaited<T> = T extends PromiseLike<any> ? Awaited<T> : T extends {} ? DeeplyAwaitedObject<T> : Awaited<T>;
|
|
48
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["utils.js"],"names":[],"mappings":"AAqBO,0EAcN;AA0CM,gJAIN;AAQM,0CAHI,MAAM,MAAM,GAAG,MAAM,CAAC,cACtB,MAAM,MAAM,GAAG,MAAM,CAAC,uBAKhC;AASM,uCALI,KAAK,SACL,MAAM,GAAC,MAAM,qBACb,gBAAgB,eACd,KAAK,CAYjB;AAUM,uHAsBN;AAmBM,oCAHI,OAAO,MAAM,GAAG,MAAM,EAAE,OAAO,CAAC,GAC9B,CAAC,MAAM,GAAC,MAAM,CAAC,EAAE,CAW7B;AA+BM,oCAHI,SAAS,GACP,SAAS,CAiBnB;AAGH;;;GAGG;AAEH;;;;;;;GAOG;AAEH;;;;;GAKG;AACH,gIAGE;AAUK,wDAHI,cAAc,YAAY,EAAE,WAAW,CAAC,GAAG;;cACmB,MAAM;GAW9E;AAMM,2CAHI,KAAK,EAAE,uCAcjB;AAOM,6FAeN;AAED;;;;;GAKG,CAAC,mFAFoB,OAAO,KAAK,QAAQ,IAAI,CAAC,gBAY7C;AAMG,sCAHI,OAAO,IAAI,EAAE,UAAU,GAAG,OAAO,IAAI,EAAE,WAAW,GAChD,QAAQ,IAAI,CAAC,CAgCtB;wBA7VU,OAAO,yBAAyB,EAAE,SAAS;;;;;;;+BAkO5C,CAAC,SAAS,YAAY,GAAG,CAAC,GAAG,QAAQ,CAAC,CAAC,GAAG,CAAC,SAAS,EAAE,GAAG,oBAAoB,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC"}
|
package/src/utils.js
CHANGED
|
@@ -82,6 +82,11 @@ export const objectMap = (original, mapFn) => {
|
|
|
82
82
|
};
|
|
83
83
|
harden(objectMap);
|
|
84
84
|
|
|
85
|
+
/**
|
|
86
|
+
*
|
|
87
|
+
* @param {Array<string | symbol>} leftNames
|
|
88
|
+
* @param {Array<string | symbol>} rightNames
|
|
89
|
+
*/
|
|
85
90
|
export const listDifference = (leftNames, rightNames) => {
|
|
86
91
|
const rightSet = new Set(rightNames);
|
|
87
92
|
return leftNames.filter(name => !rightSet.has(name));
|
|
@@ -139,15 +144,20 @@ export const applyLabelingError = (func, args, label = undefined) => {
|
|
|
139
144
|
};
|
|
140
145
|
harden(applyLabelingError);
|
|
141
146
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
147
|
+
/**
|
|
148
|
+
* @param {unknown} a
|
|
149
|
+
* @param {unknown} b
|
|
150
|
+
* @returns {-1 | 0 | 1}
|
|
151
|
+
*/
|
|
152
|
+
const compareStringified = (a, b) => {
|
|
153
|
+
const left = String(a);
|
|
154
|
+
const right = String(b);
|
|
145
155
|
// eslint-disable-next-line no-nested-ternary
|
|
146
156
|
return left < right ? -1 : left > right ? 1 : 0;
|
|
147
157
|
};
|
|
148
158
|
|
|
149
159
|
/**
|
|
150
|
-
* @param {
|
|
160
|
+
* @param {Record<string | symbol, unknown>} obj
|
|
151
161
|
* @returns {(string|symbol)[]}
|
|
152
162
|
*/
|
|
153
163
|
export const getMethodNames = obj => {
|
|
@@ -198,7 +208,8 @@ export const bindAllMethods = obj =>
|
|
|
198
208
|
getMethodNames(obj).map(name => [
|
|
199
209
|
name,
|
|
200
210
|
{
|
|
201
|
-
value: (
|
|
211
|
+
value: (/** @type {unknown[]} */ ...args) =>
|
|
212
|
+
apply(obj[name], obj, args),
|
|
202
213
|
enumerable: true,
|
|
203
214
|
},
|
|
204
215
|
]),
|
|
@@ -218,7 +229,7 @@ harden(bindAllMethods);
|
|
|
218
229
|
* - resulting type has wrapper in its name
|
|
219
230
|
*
|
|
220
231
|
* @template T
|
|
221
|
-
* @typedef {T extends PromiseLike ? Awaited<T> : T extends {} ? DeeplyAwaitedObject<T> : Awaited<T>} DeeplyAwaited
|
|
232
|
+
* @typedef {T extends PromiseLike<any> ? Awaited<T> : T extends {} ? DeeplyAwaitedObject<T> : Awaited<T>} DeeplyAwaited
|
|
222
233
|
*/
|
|
223
234
|
|
|
224
235
|
/**
|
|
@@ -241,6 +252,7 @@ export const deeplyFulfilledObject = obj => {
|
|
|
241
252
|
* @returns {<T>(fn: () => Promise<T>) => Promise<{ result: T, duration: number }>}
|
|
242
253
|
*/
|
|
243
254
|
export const makeMeasureSeconds = currentTimeMillisec => {
|
|
255
|
+
/** @param {() => any} fn */
|
|
244
256
|
const measureSeconds = async fn => {
|
|
245
257
|
const t0 = currentTimeMillisec();
|
|
246
258
|
const result = await fn();
|