@agoric/internal 0.3.3-upgrade-21-dev-07d4845.0 → 0.3.3-ymax-v0.2-alpha-dev-f741807.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/cli-utils.d.ts +2 -0
- package/src/cli-utils.d.ts.map +1 -0
- package/src/cli-utils.js +21 -0
- package/src/index.d.ts +1 -0
- package/src/index.js +1 -0
- package/src/js-utils.js +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agoric/internal",
|
|
3
|
-
"version": "0.3.3-
|
|
3
|
+
"version": "0.3.3-ymax-v0.2-alpha-dev-f741807.0+f741807",
|
|
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.
|
|
65
|
+
"atLeast": 92.99
|
|
66
66
|
},
|
|
67
|
-
"gitHead": "
|
|
67
|
+
"gitHead": "f741807aff5929acabc007380c4a057882a35147"
|
|
68
68
|
}
|
|
@@ -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"}
|
package/src/cli-utils.js
ADDED
|
@@ -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
package/src/index.js
CHANGED
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:
|
|
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) => {
|