@lodestar/utils 1.16.0-dev.8e0078b828 → 1.16.0-dev.a9dc307b85
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/lib/format.d.ts +14 -0
- package/lib/format.js +31 -0
- package/lib/format.js.map +1 -1
- package/lib/promise.d.ts +43 -19
- package/lib/promise.js +64 -87
- package/lib/promise.js.map +1 -1
- package/lib/types.d.ts +4 -0
- package/package.json +3 -3
package/lib/format.d.ts
CHANGED
|
@@ -14,4 +14,18 @@ export declare function prettyBytesShort(root: Uint8Array | string): string;
|
|
|
14
14
|
* values on explorers like beaconcha.in while improving readability of logs
|
|
15
15
|
*/
|
|
16
16
|
export declare function truncBytes(root: Uint8Array | string): string;
|
|
17
|
+
/**
|
|
18
|
+
* Format a bigint value as a decimal string
|
|
19
|
+
*/
|
|
20
|
+
export declare function formatBigDecimal(numerator: bigint, denominator: bigint, maxDecimalFactor: bigint): string;
|
|
21
|
+
/**
|
|
22
|
+
* Format wei as ETH, with up to 5 decimals
|
|
23
|
+
*
|
|
24
|
+
* if suffix is true, append ' ETH'
|
|
25
|
+
*/
|
|
26
|
+
export declare function prettyWeiToEth(wei: bigint, suffix?: boolean): string;
|
|
27
|
+
/**
|
|
28
|
+
* Format milliseconds to time format HH:MM:SS.ms
|
|
29
|
+
*/
|
|
30
|
+
export declare function prettyMsToTime(timeMs: number): string;
|
|
17
31
|
//# sourceMappingURL=format.d.ts.map
|
package/lib/format.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { toHexString } from "./bytes.js";
|
|
2
|
+
import { ETH_TO_WEI } from "./ethConversion.js";
|
|
2
3
|
/**
|
|
3
4
|
* Format bytes as `0x1234…1234`
|
|
4
5
|
* 4 bytes can represent 4294967296 values, so the chance of collision is low
|
|
@@ -24,4 +25,34 @@ export function truncBytes(root) {
|
|
|
24
25
|
const str = typeof root === "string" ? root : toHexString(root);
|
|
25
26
|
return str.slice(0, 14);
|
|
26
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* Format a bigint value as a decimal string
|
|
30
|
+
*/
|
|
31
|
+
export function formatBigDecimal(numerator, denominator, maxDecimalFactor) {
|
|
32
|
+
const full = numerator / denominator;
|
|
33
|
+
const fraction = ((numerator - full * denominator) * maxDecimalFactor) / denominator;
|
|
34
|
+
// zeros to be added post decimal are number of zeros in maxDecimalFactor - number of digits in fraction
|
|
35
|
+
const zerosPostDecimal = String(maxDecimalFactor).length - 1 - String(fraction).length;
|
|
36
|
+
return `${full}.${"0".repeat(zerosPostDecimal)}${fraction}`;
|
|
37
|
+
}
|
|
38
|
+
// display upto 5 decimal places
|
|
39
|
+
const MAX_DECIMAL_FACTOR = BigInt("100000");
|
|
40
|
+
/**
|
|
41
|
+
* Format wei as ETH, with up to 5 decimals
|
|
42
|
+
*
|
|
43
|
+
* if suffix is true, append ' ETH'
|
|
44
|
+
*/
|
|
45
|
+
export function prettyWeiToEth(wei, suffix = false) {
|
|
46
|
+
let eth = formatBigDecimal(wei, ETH_TO_WEI, MAX_DECIMAL_FACTOR);
|
|
47
|
+
if (suffix)
|
|
48
|
+
eth += " ETH";
|
|
49
|
+
return eth;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Format milliseconds to time format HH:MM:SS.ms
|
|
53
|
+
*/
|
|
54
|
+
export function prettyMsToTime(timeMs) {
|
|
55
|
+
const date = new Date(0, 0, 0, 0, 0, 0, timeMs);
|
|
56
|
+
return `${date.getHours()}:${date.getMinutes()}:${date.getSeconds()}.${date.getMilliseconds()}`;
|
|
57
|
+
}
|
|
27
58
|
//# sourceMappingURL=format.js.map
|
package/lib/format.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format.js","sourceRoot":"","sources":["../src/format.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAC,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"format.js","sourceRoot":"","sources":["../src/format.ts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AC,gBAAgB,CAAC,CAAC,MAAM,GAAG,CAAC,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC;IACvF,OAAO,GAAG,IAAI,IAAI,GAAG,CAAC,MAAM,CAAC,gBAAgB,CAAC,GAAG,QAAQ,EAAE,CAAC;AAC9D,CAAC;AAED,gCAAgC;AAChC,MAAM,kBAAkB,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;AAE5C;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,GAAW,EAAE,MAAM,GAAG,KAAK;IACxD,IAAI,GAAG,GAAG,gBAAgB,CAAC,GAAG,EAAE,UAAU,EAAE,kBAAkB,CAAC,CAAC;IAChE,IAAI,MAAM;QAAE,GAAG,IAAI,MAAM,CAAC;IAC1B,OAAO,GAAG,CAAC;AACb,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,MAAc;IAC3C,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC;IAChD,OAAO,GAAG,IAAI,CAAC,QAAQ,EAAE,IAAI,IAAI,CAAC,UAAU,EAAE,IAAI,IAAI,CAAC,UAAU,EAAE,IAAI,IAAI,CAAC,eAAe,EAAE,EAAE,CAAC;AAClG,CAAC"}
|
package/lib/promise.d.ts
CHANGED
|
@@ -1,26 +1,50 @@
|
|
|
1
|
+
import { ArrayToTuple, NonEmptyArray } from "./types.js";
|
|
1
2
|
/**
|
|
2
3
|
* While promise t is not finished, call function `fn` per `interval`
|
|
3
4
|
*/
|
|
4
5
|
export declare function callFnWhenAwait<T>(p: Promise<NonNullable<T>>, fn: () => void, interval: number): Promise<NonNullable<T>>;
|
|
5
|
-
export
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
6
|
+
export type PromiseResult<T> = {
|
|
7
|
+
promise: Promise<T>;
|
|
8
|
+
} & ({
|
|
9
|
+
status: "pending";
|
|
10
|
+
} | {
|
|
11
|
+
status: "fulfilled";
|
|
12
|
+
value: T;
|
|
13
|
+
durationMs: number;
|
|
14
|
+
} | {
|
|
15
|
+
status: "rejected";
|
|
16
|
+
reason: Error;
|
|
17
|
+
durationMs: number;
|
|
18
|
+
});
|
|
19
|
+
export type PromiseFulfilledResult<T> = PromiseResult<T> & {
|
|
20
|
+
status: "fulfilled";
|
|
21
|
+
};
|
|
22
|
+
export type PromiseRejectedResult<T> = PromiseResult<T> & {
|
|
23
|
+
status: "rejected";
|
|
24
|
+
};
|
|
21
25
|
/**
|
|
22
|
-
*
|
|
23
|
-
* @return resolved values or rejections or still pending errors corresponding to input promises
|
|
26
|
+
* Wrap a promise to an object to track the status and value of the promise
|
|
24
27
|
*/
|
|
25
|
-
export declare function
|
|
28
|
+
export declare function wrapPromise<T>(promise: PromiseLike<T>): PromiseResult<T>;
|
|
29
|
+
/**
|
|
30
|
+
* ArrayToTuple converts an `Array<T>` to `[T, ...T]`
|
|
31
|
+
*
|
|
32
|
+
* eg: `[1, 2, 3]` from type `number[]` to `[number, number, number]`
|
|
33
|
+
*/
|
|
34
|
+
type ReturnPromiseWithTuple<Tuple extends NonEmptyArray<PromiseLike<unknown>>> = {
|
|
35
|
+
[Index in keyof ArrayToTuple<Tuple>]: PromiseResult<Awaited<Tuple[Index]>>;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Two phased approach for resolving promises:
|
|
39
|
+
* - first wait `resolveTimeoutMs` or until all promises settle
|
|
40
|
+
* - then wait `raceTimeoutMs - resolveTimeoutMs` or until at least a single promise resolves
|
|
41
|
+
*
|
|
42
|
+
* Returns a list of promise results, see `PromiseResult`
|
|
43
|
+
*/
|
|
44
|
+
export declare function resolveOrRacePromises<T extends NonEmptyArray<PromiseLike<unknown>>>(promises: T, { resolveTimeoutMs, raceTimeoutMs, signal, }: {
|
|
45
|
+
resolveTimeoutMs: number;
|
|
46
|
+
raceTimeoutMs: number;
|
|
47
|
+
signal?: AbortSignal;
|
|
48
|
+
}): Promise<ReturnPromiseWithTuple<T>> | never;
|
|
49
|
+
export {};
|
|
26
50
|
//# sourceMappingURL=promise.d.ts.map
|
package/lib/promise.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ErrorAborted, TimeoutError } from "./errors.js";
|
|
1
2
|
import { sleep } from "./sleep.js";
|
|
2
3
|
/**
|
|
3
4
|
* While promise t is not finished, call function `fn` per `interval`
|
|
@@ -19,100 +20,76 @@ export async function callFnWhenAwait(p, fn, interval) {
|
|
|
19
20
|
}
|
|
20
21
|
return t;
|
|
21
22
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
23
|
+
/**
|
|
24
|
+
* Wrap a promise to an object to track the status and value of the promise
|
|
25
|
+
*/
|
|
26
|
+
export function wrapPromise(promise) {
|
|
27
|
+
const startedAt = Date.now();
|
|
28
|
+
const result = {
|
|
29
|
+
promise: promise.then((value) => {
|
|
30
|
+
result.status = "fulfilled";
|
|
31
|
+
result.value = value;
|
|
32
|
+
result.durationMs = Date.now() - startedAt;
|
|
33
|
+
return value;
|
|
34
|
+
}, (reason) => {
|
|
35
|
+
result.status = "rejected";
|
|
36
|
+
result.reason = reason;
|
|
37
|
+
result.durationMs = Date.now() - startedAt;
|
|
38
|
+
throw reason;
|
|
39
|
+
}),
|
|
40
|
+
status: "pending",
|
|
41
|
+
};
|
|
42
|
+
return result;
|
|
39
43
|
}
|
|
40
|
-
export var RaceEvent;
|
|
41
|
-
(function (RaceEvent) {
|
|
42
|
-
/** all reject/resolve before cutoff */
|
|
43
|
-
RaceEvent["precutoff"] = "precutoff-return";
|
|
44
|
-
/** cutoff reached as some were pending till cutoff **/
|
|
45
|
-
RaceEvent["cutoff"] = "cutoff-reached";
|
|
46
|
-
/** atleast one resolved till cutoff so no race required */
|
|
47
|
-
RaceEvent["resolvedatcutoff"] = "resolved-at-cutoff";
|
|
48
|
-
/** if none reject/resolve before cutoff but one resolves or all reject before timeout */
|
|
49
|
-
RaceEvent["pretimeout"] = "pretimeout-return";
|
|
50
|
-
/** timeout reached as none resolved and some were pending till timeout*/
|
|
51
|
-
RaceEvent["timeout"] = "timeout-reached";
|
|
52
|
-
// events for the promises for better tracking
|
|
53
|
-
/** promise resolved */
|
|
54
|
-
RaceEvent["resolved"] = "resolved";
|
|
55
|
-
/** promise rejected */
|
|
56
|
-
RaceEvent["rejected"] = "rejected";
|
|
57
|
-
})(RaceEvent || (RaceEvent = {}));
|
|
58
44
|
/**
|
|
59
|
-
*
|
|
60
|
-
*
|
|
45
|
+
* Two phased approach for resolving promises:
|
|
46
|
+
* - first wait `resolveTimeoutMs` or until all promises settle
|
|
47
|
+
* - then wait `raceTimeoutMs - resolveTimeoutMs` or until at least a single promise resolves
|
|
48
|
+
*
|
|
49
|
+
* Returns a list of promise results, see `PromiseResult`
|
|
61
50
|
*/
|
|
62
|
-
export async function
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
})
|
|
83
|
-
.catch((e) => {
|
|
84
|
-
eventCb(RaceEvent.rejected, Date.now() - startTime, index);
|
|
85
|
-
promisesStates[index] = { status: PromiseStatus.rejected, value: e };
|
|
86
|
-
});
|
|
87
|
-
});
|
|
88
|
-
// Wait till cutoff time unless all original promises resolve/reject early
|
|
89
|
-
await Promise.allSettled(promises.map((promise) => Promise.race([promise, cutoffPromise])));
|
|
90
|
-
if (cutoffObserved) {
|
|
91
|
-
// If any is resolved, then just simply return as we are post cutoff
|
|
92
|
-
const anyResolved = promisesStates.reduce((acc, pmState) => acc || pmState.status === PromiseStatus.resolved, false);
|
|
93
|
-
if (anyResolved) {
|
|
94
|
-
eventCb(RaceEvent.resolvedatcutoff, Date.now() - startTime);
|
|
95
|
-
return mapStatusesToResponses(promisesStates);
|
|
51
|
+
export async function resolveOrRacePromises(promises, { resolveTimeoutMs, raceTimeoutMs, signal, }) {
|
|
52
|
+
if (raceTimeoutMs <= resolveTimeoutMs) {
|
|
53
|
+
throw new Error("Race time must be greater than resolve time");
|
|
54
|
+
}
|
|
55
|
+
const resolveTimeoutError = new TimeoutError(`Given promises can't be resolved within resolveTimeoutMs=${resolveTimeoutMs}`);
|
|
56
|
+
const raceTimeoutError = new TimeoutError(`Not a any single promise be resolved in given raceTimeoutMs=${raceTimeoutMs}`);
|
|
57
|
+
const promiseResults = promises.map((p) => wrapPromise(p));
|
|
58
|
+
promises = promiseResults.map((p) => p.promise);
|
|
59
|
+
try {
|
|
60
|
+
await Promise.race([
|
|
61
|
+
Promise.allSettled(promises),
|
|
62
|
+
sleep(resolveTimeoutMs, signal).then(() => {
|
|
63
|
+
throw resolveTimeoutError;
|
|
64
|
+
}),
|
|
65
|
+
]);
|
|
66
|
+
return promiseResults;
|
|
67
|
+
}
|
|
68
|
+
catch (err) {
|
|
69
|
+
if (err instanceof ErrorAborted) {
|
|
70
|
+
return promiseResults;
|
|
96
71
|
}
|
|
97
|
-
|
|
98
|
-
|
|
72
|
+
if (err !== resolveTimeoutError) {
|
|
73
|
+
throw err;
|
|
99
74
|
}
|
|
100
75
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
(_e) => { });
|
|
110
|
-
if (timeoutObserved) {
|
|
111
|
-
eventCb(RaceEvent.timeout, Date.now() - startTime);
|
|
76
|
+
try {
|
|
77
|
+
await Promise.race([
|
|
78
|
+
Promise.any(promises),
|
|
79
|
+
sleep(raceTimeoutMs - resolveTimeoutMs, signal).then(() => {
|
|
80
|
+
throw raceTimeoutError;
|
|
81
|
+
}),
|
|
82
|
+
]);
|
|
83
|
+
return promiseResults;
|
|
112
84
|
}
|
|
113
|
-
|
|
114
|
-
|
|
85
|
+
catch (err) {
|
|
86
|
+
if (err instanceof ErrorAborted) {
|
|
87
|
+
return promiseResults;
|
|
88
|
+
}
|
|
89
|
+
if (err !== raceTimeoutError && !(err instanceof AggregateError)) {
|
|
90
|
+
throw err;
|
|
91
|
+
}
|
|
115
92
|
}
|
|
116
|
-
return
|
|
93
|
+
return promiseResults;
|
|
117
94
|
}
|
|
118
95
|
//# sourceMappingURL=promise.js.map
|
package/lib/promise.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"promise.js","sourceRoot":"","sources":["../src/promise.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAC,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"promise.js","sourceRoot":"","sources":["../src/promise.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAE,YAAY,EAAC,MAAM,aAAa,CAAC;AACvD,OAAO,EAAC,KAAK,EAAC,MAAM,YAAY,CAAC;AAGjC;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,CAA0B,EAC1B,EAAc,EACd,QAAgB;IAEhB,IAAI,CAAC,GAA+B,SAAS,CAAC;IAC9C,MAAM,KAAK,GAAG,KAAK,IAAwB,EAAE;QAC3C,OAAO,CAAC,KAAK,SAAS,EAAE;YACtB,MAAM,KAAK,CAAC,QAAQ,CAAC,CAA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AAY,cAAc,CAAC,EAAE;YAChE,MAAM,GAAG,CAAC;SACX;KACF;IAED,OAAO,cAAc,CAAC;AACxB,CAAC"}
|
package/lib/types.d.ts
CHANGED
|
@@ -7,4 +7,8 @@ export type RecursivePartial<T> = {
|
|
|
7
7
|
};
|
|
8
8
|
/** Type safe wrapper for Number constructor that takes 'any' */
|
|
9
9
|
export declare function bnToNum(bn: bigint): number;
|
|
10
|
+
export type NonEmptyArray<T> = [T, ...T[]];
|
|
11
|
+
export type ArrayToTuple<Tuple extends NonEmptyArray<unknown>> = {
|
|
12
|
+
[Index in keyof Tuple]: Tuple[Index];
|
|
13
|
+
};
|
|
10
14
|
//# sourceMappingURL=types.d.ts.map
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"bugs": {
|
|
12
12
|
"url": "https://github.com/ChainSafe/lodestar/issues"
|
|
13
13
|
},
|
|
14
|
-
"version": "1.16.0-dev.
|
|
14
|
+
"version": "1.16.0-dev.a9dc307b85",
|
|
15
15
|
"type": "module",
|
|
16
16
|
"exports": "./lib/index.js",
|
|
17
17
|
"files": [
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
},
|
|
40
40
|
"types": "lib/index.d.ts",
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@chainsafe/as-sha256": "^0.
|
|
42
|
+
"@chainsafe/as-sha256": "^0.4.1",
|
|
43
43
|
"any-signal": "3.0.1",
|
|
44
44
|
"bigint-buffer": "^1.1.5",
|
|
45
45
|
"case": "^1.6.3",
|
|
@@ -58,5 +58,5 @@
|
|
|
58
58
|
"beacon",
|
|
59
59
|
"blockchain"
|
|
60
60
|
],
|
|
61
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "3e1f618cecf16786d90abda98bc0efb4f7250c28"
|
|
62
62
|
}
|