@agoric/internal 0.3.3-upgrade-19-dev-c605745.0 → 0.3.3-upgrade-19-dev-2a71f04.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 -4
- package/src/js-utils.d.ts +1 -0
- package/src/js-utils.d.ts.map +1 -1
- package/src/js-utils.js +14 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agoric/internal",
|
|
3
|
-
"version": "0.3.3-upgrade-19-dev-
|
|
3
|
+
"version": "0.3.3-upgrade-19-dev-2a71f04.0+2a71f04",
|
|
4
4
|
"description": "Externally unsupported utilities internal to agoric-sdk",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"lint:types": "tsc"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@agoric/base-zone": "0.1.1-upgrade-19-dev-
|
|
23
|
+
"@agoric/base-zone": "0.1.1-upgrade-19-dev-2a71f04.0+2a71f04",
|
|
24
24
|
"@endo/common": "^1.2.9",
|
|
25
25
|
"@endo/errors": "^1.2.9",
|
|
26
26
|
"@endo/far": "^1.1.10",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"jessie.js": "^0.3.4"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@agoric/cosmic-proto": "0.4.1-upgrade-19-dev-
|
|
37
|
+
"@agoric/cosmic-proto": "0.4.1-upgrade-19-dev-2a71f04.0+2a71f04",
|
|
38
38
|
"@endo/exo": "^1.5.8",
|
|
39
39
|
"@endo/init": "^1.1.8",
|
|
40
40
|
"ava": "^5.3.0",
|
|
@@ -60,5 +60,5 @@
|
|
|
60
60
|
"typeCoverage": {
|
|
61
61
|
"atLeast": 93.04
|
|
62
62
|
},
|
|
63
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "2a71f04176f1a27be8e0356595d3dcd62f6d9186"
|
|
64
64
|
}
|
package/src/js-utils.d.ts
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
export const logLevels: readonly ["debug", "log", "info", "warn", "error"];
|
|
6
6
|
export function deepCopyJsonable<T>(value: T): T;
|
|
7
7
|
export function deepMapObject(obj: object, mapper: (value: any, name: string, record: object) => any): object;
|
|
8
|
+
export function objectMapMutable<O extends Record<PropertyKey, any>, V>(obj: O, mapFn: <K extends keyof O>(value: O[K], key: K) => V): { [K in keyof O]: V; };
|
|
8
9
|
export function makeMeasureSeconds(currentTimeMillisec: () => number): <T>(fn: () => Promise<T>) => Promise<{
|
|
9
10
|
result: T;
|
|
10
11
|
duration: number;
|
package/src/js-utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"js-utils.d.ts","sourceRoot":"","sources":["js-utils.js"],"names":[],"mappings":"AAEA;;;GAGG;AAEH,2EAMG;
|
|
1
|
+
{"version":3,"file":"js-utils.d.ts","sourceRoot":"","sources":["js-utils.js"],"names":[],"mappings":"AAEA;;;GAGG;AAEH,2EAMG;AAkBI,iCAJM,CAAC,SACH,CAAC,GACC,CAAC,CAE4D;AAiDnE,mCAJI,MAAM,UACN,CAAC,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,GAAG,GAC/C,MAAM,CAGuC;AASnD,iCANiC,CAAC,SAA3B,MAAM,CAAC,WAAW,EAAE,GAAG,CAAE,EAC1B,CAAC,OACH,CAAC,SACD,CAAC,CAAC,SAAS,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,GAC3C,GAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,GAAE,CAKjC;AASM,wDAFI,MAAM,MAAM,IAIR,CAAC,MACH,MAAM,OAAO,CAAC,CAAC,CAAC,KACd,OAAO,CAAC;IAAE,MAAM,EAAE,CAAC,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC,CAStD;uBAnGa,CAAC,OAAO,SAAS,EAAE,2DAAkB,MAAM,CAAC;6BAE5C,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC"}
|
package/src/js-utils.js
CHANGED
|
@@ -18,6 +18,8 @@ Object.freeze(logLevels);
|
|
|
18
18
|
|
|
19
19
|
/** @typedef {Pick<Console, LogLevel>} LimitedConsole */
|
|
20
20
|
|
|
21
|
+
const { entries, fromEntries } = Object;
|
|
22
|
+
|
|
21
23
|
/**
|
|
22
24
|
* Deep-copy a value by round-tripping it through JSON (which drops
|
|
23
25
|
* function/symbol/undefined values and properties that are non-enumerable
|
|
@@ -79,6 +81,18 @@ const deepMapObjectInternal = (value, name, container, mapper) => {
|
|
|
79
81
|
export const deepMapObject = (obj, mapper) =>
|
|
80
82
|
deepMapObjectInternal(obj, undefined, undefined, mapper);
|
|
81
83
|
|
|
84
|
+
/**
|
|
85
|
+
* @template {Record<PropertyKey, any>} O
|
|
86
|
+
* @template V
|
|
87
|
+
* @param {O} obj
|
|
88
|
+
* @param {<K extends keyof O>(value: O[K], key: K) => V} mapFn
|
|
89
|
+
* @returns {{ [K in keyof O]: V }}
|
|
90
|
+
*/
|
|
91
|
+
export const objectMapMutable = (obj, mapFn) => {
|
|
92
|
+
const newEntries = entries(obj).map(([k, v]) => [k, mapFn(v, k)]);
|
|
93
|
+
return /** @type {{ [K in keyof O]: V }} */ (fromEntries(newEntries));
|
|
94
|
+
};
|
|
95
|
+
|
|
82
96
|
/**
|
|
83
97
|
* Returns a function that uses a millisecond-based current-time capability
|
|
84
98
|
* (such as `performance.now`) to measure execution duration of an async
|