@agoric/internal 0.3.3-upgrade-21-dev-07d4845.0 → 0.3.3-ymax-v0.2-alpha-dev-a527ef4.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.3.3-upgrade-21-dev-07d4845.0+07d4845",
3
+ "version": "0.3.3-ymax-v0.2-alpha-dev-a527ef4.0+a527ef4",
4
4
  "description": "Externally unsupported utilities internal to agoric-sdk",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -62,7 +62,7 @@
62
62
  "access": "public"
63
63
  },
64
64
  "typeCoverage": {
65
- "atLeast": 92.98
65
+ "atLeast": 92.99
66
66
  },
67
- "gitHead": "07d4845c9599083aecbf807668443865d0de0498"
67
+ "gitHead": "a527ef456b970107c2395833dce9abd87689959e"
68
68
  }
@@ -0,0 +1,2 @@
1
+ export function toCLIOptions(record: Record<string, undefined | boolean | string | string[]>): string[];
2
+ //# sourceMappingURL=cli-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli-utils.d.ts","sourceRoot":"","sources":["cli-utils.js"],"names":[],"mappings":"AAUO,qCAJI,MAAM,CAAC,MAAM,EAAE,SAAS,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,EAAE,CAAC,GAErD,MAAM,EAAE,CAYjB"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Convert a string-keyed object into an array of CLI options, using each key as
3
+ * the name of a GNU-style long option `--${key}`, ignoring each key with an
4
+ * undefined value and converting boolean values into no-argument `--${key}` or
5
+ * `--no-${key}` options.
6
+ *
7
+ * @param {Record<string, undefined | boolean | string | string[]>} record -
8
+ * e.g. { color: 'blue' }
9
+ * @returns {string[]} - e.g. ['--color', 'blue']
10
+ */
11
+ export const toCLIOptions = record =>
12
+ Object.entries(record).flatMap(([key, value]) => {
13
+ if (value === undefined) return [];
14
+ if (value === true) return [`--${key}`];
15
+ if (value === false) return [`--no-${key}`];
16
+ if (Array.isArray(value)) {
17
+ // Represent as a repeated option.
18
+ return value.flatMap(v => [`--${key}`, v]);
19
+ }
20
+ return [`--${key}`, value];
21
+ });
package/src/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ export * from "./cli-utils.js";
1
2
  export * from "./config.js";
2
3
  export * from "./debug.js";
3
4
  export * from "./errors.js";
package/src/index.js CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  /// <reference types="ses" />
4
4
 
5
+ export * from './cli-utils.js';
5
6
  export * from './config.js';
6
7
  export * from './debug.js';
7
8
  export * from './errors.js';
package/src/js-utils.js CHANGED
@@ -69,7 +69,7 @@ export const deepCopyJsonable = value => JSON.parse(JSON.stringify(value));
69
69
  * @param {O[K]} value
70
70
  * @param {K | undefined} name
71
71
  * @param {O | undefined} container
72
- * @param {(value: O[K], name: K, record: O) => O[K] | M} mapper
72
+ * @param {(value: O[K], name: string, record: O) => O[K] | M} mapper
73
73
  * @returns {O[K] | M | { [K2 in keyof O[K]]: O[K][K2] | M }}
74
74
  */
75
75
  const deepMapObjectInternal = (value, name, container, mapper) => {