@agoric/internal 0.2.2-dev-3b56195.0 → 0.2.2-dev-7c9639a.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agoric/internal",
3
- "version": "0.2.2-dev-3b56195.0+3b56195",
3
+ "version": "0.2.2-dev-7c9639a.0+7c9639a",
4
4
  "description": "Externally unsupported utilities internal to agoric-sdk",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -36,5 +36,5 @@
36
36
  "publishConfig": {
37
37
  "access": "public"
38
38
  },
39
- "gitHead": "3b56195a9451466b86a81ff26d08b5cab15fdfcf"
39
+ "gitHead": "7c9639afbbe180f71a4f5523c1dfe115732e1289"
40
40
  }
package/src/config.js CHANGED
@@ -1,3 +1,4 @@
1
+ // @ts-check
1
2
  /** @file
2
3
  *
3
4
  * Some of this config info may make more sense in a particular package. However
package/src/utils.d.ts CHANGED
@@ -37,6 +37,7 @@ export function PromiseAllOrErrors<T>(values: readonly (T | PromiseLike<T>)[]):
37
37
  * ) => Promise<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
+ export function assertAllDefined<T extends Record<string, unknown>>(obj: T): asserts obj is Required<T>;
40
41
  export type Remotable = import('@endo/marshal/src/types').Remotable;
41
42
  export type DeeplyAwaitedObject<T extends {}> = { [K in keyof T]: DeeplyAwaited<T[K]>; };
42
43
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["utils.js"],"names":[],"mappings":"AA0BO,0EAcN;AA0CM,gJAIN;AAQM,0CAHI,MAAM,MAAM,GAAG,MAAM,CAAC,cACtB,MAAM,MAAM,GAAG,MAAM,CAAC,uBAKhC;AASM,uCALI,KAAK,SACL,MAA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,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;AAYG,wGAUN;wBAhZa,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
@@ -1,3 +1,4 @@
1
+ // @ts-check
1
2
  import { E } from '@endo/eventual-send';
2
3
  import { deeplyFulfilled, isObject } from '@endo/marshal';
3
4
  import { isPromise } from '@endo/promise-kit';
@@ -381,3 +382,25 @@ export const fsStreamReady = stream =>
381
382
  stream.on('ready', onReady);
382
383
  stream.on('error', onError);
383
384
  });
385
+
386
+ /**
387
+ * Concise way to check values are available from object literal shorthand.
388
+ * Throws error message to specify the missing values.
389
+ *
390
+ * @template {Record<string, unknown>} T
391
+ * @param {T} obj
392
+ * @throws if any value in the object entries is not defined
393
+ * @returns {asserts obj is Required<T>}
394
+ */
395
+
396
+ export const assertAllDefined = obj => {
397
+ const missing = [];
398
+ for (const [key, val] of Object.entries(obj)) {
399
+ if (val === undefined) {
400
+ missing.push(key);
401
+ }
402
+ }
403
+ if (missing.length > 0) {
404
+ Fail`missing ${q(missing)}`;
405
+ }
406
+ };