@agoric/internal 0.2.2-dev-0f75764.0 → 0.2.2-dev-e3a7775.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/src/utils.d.ts +3 -4
- package/src/utils.d.ts.map +1 -1
- package/src/utils.js +39 -23
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-e3a7775.0+e3a7775",
|
|
4
4
|
"description": "Externally unsupported utilities internal to agoric-sdk",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -37,5 +37,5 @@
|
|
|
37
37
|
"publishConfig": {
|
|
38
38
|
"access": "public"
|
|
39
39
|
},
|
|
40
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "e3a77757bcef3e2239bd34fd450d7c9500b46571"
|
|
41
41
|
}
|
package/src/utils.d.ts
CHANGED
|
@@ -38,10 +38,9 @@ export function PromiseAllOrErrors<T>(values: readonly (T | PromiseLike<T>)[]):
|
|
|
38
38
|
*/ export const aggregateTryFinally: <T>(trier: () => Promise<T>, finalizer: (error?: unknown) => Promise<void>) => Promise<T>;
|
|
39
39
|
export function fsStreamReady(stream: import("fs").ReadStream | import("fs").WriteStream): Promise<void>;
|
|
40
40
|
export function assertAllDefined<T extends Record<string, unknown>>(obj: T): asserts obj is AllDefined<T>;
|
|
41
|
-
|
|
42
|
-
export
|
|
43
|
-
export function
|
|
44
|
-
export function untilTrue(boolFunc: () => unknown): AsyncIterable<null>;
|
|
41
|
+
export const forever: AsyncIterable<undefined>;
|
|
42
|
+
export function whileTrue<T>(produce: () => T): AsyncIterable<Awaited<T>>;
|
|
43
|
+
export function untilTrue<T>(produce: () => T): AsyncIterable<Awaited<T>>;
|
|
45
44
|
export type Remotable = import('@endo/marshal/src/types').Remotable;
|
|
46
45
|
export type DeeplyAwaitedObject<T extends {}> = { [K in keyof T]: DeeplyAwaited<T[K]>; };
|
|
47
46
|
/**
|
package/src/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["utils.js"],"names":[],"mappings":"AA4BO,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;AAgCM,oCAHI,GAAG,GACD,CAAC,MAAM,GAAC,MAAM,CAAC,EAAE,CAqB7B;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;AAiBG,0GAUN;
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["utils.js"],"names":[],"mappings":"AA4BO,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;AAgCM,oCAHI,GAAG,GACD,CAAC,MAAM,GAAC,MAAM,CAAC,EAAE,CAqB7B;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;AAiBG,0GAUN;AAQD,+CAAoD;AAU7C,0EAUH;AAUG,0EAaH;wBAxcU,OAAO,yBAAyB,EAAE,SAAS;;;;;;;+BA+P5C,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
|
@@ -411,37 +411,53 @@ export const assertAllDefined = obj => {
|
|
|
411
411
|
}
|
|
412
412
|
};
|
|
413
413
|
|
|
414
|
-
|
|
414
|
+
/** @type {IteratorResult<undefined, never>} */
|
|
415
|
+
const notDone = harden({ done: false, value: undefined });
|
|
415
416
|
|
|
416
|
-
/** @type {
|
|
417
|
-
|
|
417
|
+
/** @type {IteratorResult<never, void>} */
|
|
418
|
+
const alwaysDone = harden({ done: true, value: undefined });
|
|
419
|
+
|
|
420
|
+
export const forever = asyncGenerate(() => notDone);
|
|
418
421
|
|
|
419
422
|
/**
|
|
420
|
-
* @
|
|
421
|
-
*
|
|
423
|
+
* @template T
|
|
424
|
+
* @param {() => T} produce
|
|
425
|
+
* The value of `await produce()` is used for its truthiness vs falsiness.
|
|
422
426
|
* IOW, it is coerced to a boolean so the caller need not bother doing this
|
|
423
427
|
* themselves.
|
|
424
|
-
* @returns {AsyncIterable<
|
|
428
|
+
* @returns {AsyncIterable<Awaited<T>>}
|
|
425
429
|
*/
|
|
426
|
-
export const whileTrue =
|
|
427
|
-
asyncGenerate(() =>
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
}
|
|
432
|
-
|
|
430
|
+
export const whileTrue = produce =>
|
|
431
|
+
asyncGenerate(async () => {
|
|
432
|
+
const value = await produce();
|
|
433
|
+
if (!value) {
|
|
434
|
+
return alwaysDone;
|
|
435
|
+
}
|
|
436
|
+
return harden({
|
|
437
|
+
done: false,
|
|
438
|
+
value,
|
|
439
|
+
});
|
|
440
|
+
});
|
|
433
441
|
|
|
434
442
|
/**
|
|
435
|
-
* @
|
|
436
|
-
*
|
|
443
|
+
* @template T
|
|
444
|
+
* @param {() => T} produce
|
|
445
|
+
* The value of `await produce()` is used for its truthiness vs falsiness.
|
|
437
446
|
* IOW, it is coerced to a boolean so the caller need not bother doing this
|
|
438
447
|
* themselves.
|
|
439
|
-
* @returns {AsyncIterable<
|
|
448
|
+
* @returns {AsyncIterable<Awaited<T>>}
|
|
440
449
|
*/
|
|
441
|
-
export const untilTrue =
|
|
442
|
-
asyncGenerate(() =>
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
450
|
+
export const untilTrue = produce =>
|
|
451
|
+
asyncGenerate(async () => {
|
|
452
|
+
const value = await produce();
|
|
453
|
+
if (value) {
|
|
454
|
+
return harden({
|
|
455
|
+
done: true,
|
|
456
|
+
value,
|
|
457
|
+
});
|
|
458
|
+
}
|
|
459
|
+
return harden({
|
|
460
|
+
done: false,
|
|
461
|
+
value,
|
|
462
|
+
});
|
|
463
|
+
});
|