@naturalcycles/js-lib 15.92.0 → 15.93.1
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.
|
@@ -31,10 +31,10 @@ const DATE_TIME_REGEX_LOOSE = /^(\d{4})-(\d{2})-(\d{2})([Tt\s](\d{2}):?(\d{2})?:
|
|
|
31
31
|
* Supports 2 forms:
|
|
32
32
|
* 1. 2023-03-03
|
|
33
33
|
* 2. 2023-03-03T05:10:02
|
|
34
|
-
* Ok, now it allows arbitrary stuff after `:ss`, to allow millis/timezone info
|
|
35
|
-
*
|
|
34
|
+
* Ok, now it allows arbitrary stuff after `:ss`, to allow millis/timezone info.
|
|
35
|
+
* Millis (up to 3 digits after `.`) are taken into account, timezone info is not.
|
|
36
36
|
*/
|
|
37
|
-
const DATE_TIME_REGEX_STRICT = /^(\d{4})-(\d{2})-(\d{2})[Tt\s](\d{2}):(\d{2}):(\d{2})
|
|
37
|
+
const DATE_TIME_REGEX_STRICT = /^(\d{4})-(\d{2})-(\d{2})[Tt\s](\d{2}):(\d{2}):(\d{2})(?:\.(\d{1,3}))?/;
|
|
38
38
|
const DATE_REGEX_STRICT = /^(\d\d\d\d)-(\d\d)-(\d\d)$/;
|
|
39
39
|
export class LocalTime {
|
|
40
40
|
$date;
|
|
@@ -789,7 +789,10 @@ class LocalTimeFactory {
|
|
|
789
789
|
};
|
|
790
790
|
if (!this.isDateTimeObjectValid(o))
|
|
791
791
|
return;
|
|
792
|
-
|
|
792
|
+
const d = this.createDateFromDateTimeObject(o);
|
|
793
|
+
if (m[7])
|
|
794
|
+
d.setMilliseconds(Number(m[7].padEnd(3, '0')));
|
|
795
|
+
return d;
|
|
793
796
|
}
|
|
794
797
|
parseLooselyOrUndefined(s) {
|
|
795
798
|
if (!s || typeof s !== 'string')
|
package/dist/promise/pRetry.d.ts
CHANGED
|
@@ -22,10 +22,16 @@ export interface PRetryOptions {
|
|
|
22
22
|
*/
|
|
23
23
|
maxAttempts?: number;
|
|
24
24
|
/**
|
|
25
|
+
* Delay before the first retry, in milliseconds.
|
|
26
|
+
* Each subsequent retry waits `delayMultiplier` times longer than the previous one.
|
|
27
|
+
* E.g with defaults (delay=1000, delayMultiplier=2) retries wait 1000, 2000, 4000 ms.
|
|
28
|
+
*
|
|
25
29
|
* @default 1000 ms
|
|
26
30
|
*/
|
|
27
31
|
delay?: number;
|
|
28
32
|
/**
|
|
33
|
+
* Multiplier applied to the delay after each retry ("Exponential back-off").
|
|
34
|
+
*
|
|
29
35
|
* @default 2
|
|
30
36
|
*/
|
|
31
37
|
delayMultiplier?: number;
|
package/dist/promise/pRetry.js
CHANGED
|
@@ -60,8 +60,9 @@ export async function pRetry(fn, opt = {}) {
|
|
|
60
60
|
throw _errorDataAppend(err, opt.errorData);
|
|
61
61
|
}
|
|
62
62
|
// Retry after delay
|
|
63
|
-
delay *= delayMultiplier;
|
|
64
63
|
await pDelay(delay);
|
|
64
|
+
// Increase the delay for the next possible retry (exponential back-off)
|
|
65
|
+
delay *= delayMultiplier;
|
|
65
66
|
// back to while(true) loop
|
|
66
67
|
}
|
|
67
68
|
}
|
package/package.json
CHANGED
|
@@ -69,10 +69,11 @@ const DATE_TIME_REGEX_LOOSE = /^(\d{4})-(\d{2})-(\d{2})([Tt\s](\d{2}):?(\d{2})?:
|
|
|
69
69
|
* Supports 2 forms:
|
|
70
70
|
* 1. 2023-03-03
|
|
71
71
|
* 2. 2023-03-03T05:10:02
|
|
72
|
-
* Ok, now it allows arbitrary stuff after `:ss`, to allow millis/timezone info
|
|
73
|
-
*
|
|
72
|
+
* Ok, now it allows arbitrary stuff after `:ss`, to allow millis/timezone info.
|
|
73
|
+
* Millis (up to 3 digits after `.`) are taken into account, timezone info is not.
|
|
74
74
|
*/
|
|
75
|
-
const DATE_TIME_REGEX_STRICT =
|
|
75
|
+
const DATE_TIME_REGEX_STRICT =
|
|
76
|
+
/^(\d{4})-(\d{2})-(\d{2})[Tt\s](\d{2}):(\d{2}):(\d{2})(?:\.(\d{1,3}))?/
|
|
76
77
|
const DATE_REGEX_STRICT = /^(\d\d\d\d)-(\d\d)-(\d\d)$/
|
|
77
78
|
|
|
78
79
|
export class LocalTime {
|
|
@@ -924,7 +925,9 @@ class LocalTimeFactory {
|
|
|
924
925
|
second: Number(m[6]) || 0,
|
|
925
926
|
}
|
|
926
927
|
if (!this.isDateTimeObjectValid(o)) return
|
|
927
|
-
|
|
928
|
+
const d = this.createDateFromDateTimeObject(o)
|
|
929
|
+
if (m[7]) d.setMilliseconds(Number(m[7].padEnd(3, '0')))
|
|
930
|
+
return d
|
|
928
931
|
}
|
|
929
932
|
|
|
930
933
|
private parseLooselyOrUndefined(s: string | undefined | null): Date | undefined {
|
package/src/promise/pRetry.ts
CHANGED
|
@@ -31,11 +31,17 @@ export interface PRetryOptions {
|
|
|
31
31
|
maxAttempts?: number
|
|
32
32
|
|
|
33
33
|
/**
|
|
34
|
+
* Delay before the first retry, in milliseconds.
|
|
35
|
+
* Each subsequent retry waits `delayMultiplier` times longer than the previous one.
|
|
36
|
+
* E.g with defaults (delay=1000, delayMultiplier=2) retries wait 1000, 2000, 4000 ms.
|
|
37
|
+
*
|
|
34
38
|
* @default 1000 ms
|
|
35
39
|
*/
|
|
36
40
|
delay?: number
|
|
37
41
|
|
|
38
42
|
/**
|
|
43
|
+
* Multiplier applied to the delay after each retry ("Exponential back-off").
|
|
44
|
+
*
|
|
39
45
|
* @default 2
|
|
40
46
|
*/
|
|
41
47
|
delayMultiplier?: number
|
|
@@ -174,8 +180,9 @@ export async function pRetry<T>(
|
|
|
174
180
|
}
|
|
175
181
|
|
|
176
182
|
// Retry after delay
|
|
177
|
-
delay *= delayMultiplier
|
|
178
183
|
await pDelay(delay)
|
|
184
|
+
// Increase the delay for the next possible retry (exponential back-off)
|
|
185
|
+
delay *= delayMultiplier
|
|
179
186
|
// back to while(true) loop
|
|
180
187
|
}
|
|
181
188
|
}
|