@naturalcycles/js-lib 14.245.0 → 14.246.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.
|
@@ -26,7 +26,6 @@ const VALID_DAYS_OF_WEEK = new Set([1, 2, 3, 4, 5, 6, 7]);
|
|
|
26
26
|
* It supports 2 forms:
|
|
27
27
|
* 1. 2023-03-03
|
|
28
28
|
* 2. 2023-03-03T05:10:02
|
|
29
|
-
* // todo: make it even looser, like Day.js
|
|
30
29
|
*/
|
|
31
30
|
const DATE_TIME_REGEX_LOOSE = /^(\d{4})-(\d{2})-(\d{2})([Tt\s](\d{2}):?(\d{2})?:?(\d{2})?)?/;
|
|
32
31
|
/**
|
|
@@ -36,7 +35,7 @@ const DATE_TIME_REGEX_LOOSE = /^(\d{4})-(\d{2})-(\d{2})([Tt\s](\d{2}):?(\d{2})?:
|
|
|
36
35
|
* Ok, now it allows arbitrary stuff after `:ss`, to allow millis/timezone info,
|
|
37
36
|
* but it will not take it into account.
|
|
38
37
|
*/
|
|
39
|
-
const DATE_TIME_REGEX_STRICT = /^(\d{4})-(\d{2})-(\d{2})
|
|
38
|
+
const DATE_TIME_REGEX_STRICT = /^(\d{4})-(\d{2})-(\d{2})[Tt\s](\d{2}):(\d{2}):(\d{2})/;
|
|
40
39
|
const DATE_REGEX_STRICT = /^(\d\d\d\d)-(\d\d)-(\d\d)$/;
|
|
41
40
|
class LocalTime {
|
|
42
41
|
constructor($date) {
|
package/dist/log/commonLogger.js
CHANGED
|
@@ -5,7 +5,8 @@ exports.commonLoggerMinLevel = commonLoggerMinLevel;
|
|
|
5
5
|
exports.commonLoggerPipe = commonLoggerPipe;
|
|
6
6
|
exports.commonLoggerPrefix = commonLoggerPrefix;
|
|
7
7
|
exports.commonLoggerCreate = commonLoggerCreate;
|
|
8
|
-
|
|
8
|
+
// copy-pasted to avoid weird circular dependency
|
|
9
|
+
const _noop = (..._args) => undefined;
|
|
9
10
|
exports.commonLogLevelNumber = {
|
|
10
11
|
log: 10,
|
|
11
12
|
warn: 20,
|
|
@@ -17,9 +18,9 @@ exports.commonLogLevelNumber = {
|
|
|
17
18
|
* @experimental
|
|
18
19
|
*/
|
|
19
20
|
exports.commonLoggerNoop = {
|
|
20
|
-
log:
|
|
21
|
-
warn:
|
|
22
|
-
error:
|
|
21
|
+
log: _noop,
|
|
22
|
+
warn: _noop,
|
|
23
|
+
error: _noop,
|
|
23
24
|
};
|
|
24
25
|
/**
|
|
25
26
|
* Creates a "child" logger that is "limited" to the specified CommonLogLevel.
|
|
@@ -28,11 +29,11 @@ function commonLoggerMinLevel(logger, minLevel, mutate = false) {
|
|
|
28
29
|
const level = exports.commonLogLevelNumber[minLevel];
|
|
29
30
|
if (mutate) {
|
|
30
31
|
if (level > exports.commonLogLevelNumber['log']) {
|
|
31
|
-
logger.log =
|
|
32
|
+
logger.log = _noop;
|
|
32
33
|
if (level > exports.commonLogLevelNumber['warn']) {
|
|
33
|
-
logger.warn =
|
|
34
|
+
logger.warn = _noop;
|
|
34
35
|
if (level > exports.commonLogLevelNumber['error']) {
|
|
35
|
-
logger.error =
|
|
36
|
+
logger.error = _noop;
|
|
36
37
|
}
|
|
37
38
|
}
|
|
38
39
|
}
|
|
@@ -47,8 +48,8 @@ function commonLoggerMinLevel(logger, minLevel, mutate = false) {
|
|
|
47
48
|
return exports.commonLoggerNoop;
|
|
48
49
|
}
|
|
49
50
|
return {
|
|
50
|
-
log:
|
|
51
|
-
warn: level <= exports.commonLogLevelNumber['warn'] ? logger.warn.bind(logger) :
|
|
51
|
+
log: _noop, // otherwise it is "log everything" logger (same logger as input)
|
|
52
|
+
warn: level <= exports.commonLogLevelNumber['warn'] ? logger.warn.bind(logger) : _noop,
|
|
52
53
|
error: logger.error.bind(logger), // otherwise it's "log nothing" logger (same as noopLogger)
|
|
53
54
|
};
|
|
54
55
|
}
|
|
@@ -23,7 +23,6 @@ const VALID_DAYS_OF_WEEK = new Set([1, 2, 3, 4, 5, 6, 7]);
|
|
|
23
23
|
* It supports 2 forms:
|
|
24
24
|
* 1. 2023-03-03
|
|
25
25
|
* 2. 2023-03-03T05:10:02
|
|
26
|
-
* // todo: make it even looser, like Day.js
|
|
27
26
|
*/
|
|
28
27
|
const DATE_TIME_REGEX_LOOSE = /^(\d{4})-(\d{2})-(\d{2})([Tt\s](\d{2}):?(\d{2})?:?(\d{2})?)?/;
|
|
29
28
|
/**
|
|
@@ -33,7 +32,7 @@ const DATE_TIME_REGEX_LOOSE = /^(\d{4})-(\d{2})-(\d{2})([Tt\s](\d{2}):?(\d{2})?:
|
|
|
33
32
|
* Ok, now it allows arbitrary stuff after `:ss`, to allow millis/timezone info,
|
|
34
33
|
* but it will not take it into account.
|
|
35
34
|
*/
|
|
36
|
-
const DATE_TIME_REGEX_STRICT = /^(\d{4})-(\d{2})-(\d{2})
|
|
35
|
+
const DATE_TIME_REGEX_STRICT = /^(\d{4})-(\d{2})-(\d{2})[Tt\s](\d{2}):(\d{2}):(\d{2})/;
|
|
37
36
|
const DATE_REGEX_STRICT = /^(\d\d\d\d)-(\d\d)-(\d\d)$/;
|
|
38
37
|
export class LocalTime {
|
|
39
38
|
constructor($date) {
|
package/package.json
CHANGED
|
@@ -57,7 +57,6 @@ const VALID_DAYS_OF_WEEK = new Set([1, 2, 3, 4, 5, 6, 7])
|
|
|
57
57
|
* It supports 2 forms:
|
|
58
58
|
* 1. 2023-03-03
|
|
59
59
|
* 2. 2023-03-03T05:10:02
|
|
60
|
-
* // todo: make it even looser, like Day.js
|
|
61
60
|
*/
|
|
62
61
|
const DATE_TIME_REGEX_LOOSE = /^(\d{4})-(\d{2})-(\d{2})([Tt\s](\d{2}):?(\d{2})?:?(\d{2})?)?/
|
|
63
62
|
/**
|
|
@@ -67,7 +66,7 @@ const DATE_TIME_REGEX_LOOSE = /^(\d{4})-(\d{2})-(\d{2})([Tt\s](\d{2}):?(\d{2})?:
|
|
|
67
66
|
* Ok, now it allows arbitrary stuff after `:ss`, to allow millis/timezone info,
|
|
68
67
|
* but it will not take it into account.
|
|
69
68
|
*/
|
|
70
|
-
const DATE_TIME_REGEX_STRICT = /^(\d{4})-(\d{2})-(\d{2})
|
|
69
|
+
const DATE_TIME_REGEX_STRICT = /^(\d{4})-(\d{2})-(\d{2})[Tt\s](\d{2}):(\d{2}):(\d{2})/
|
|
71
70
|
const DATE_REGEX_STRICT = /^(\d\d\d\d)-(\d\d)-(\d\d)$/
|
|
72
71
|
|
|
73
72
|
export class LocalTime {
|
package/src/log/commonLogger.ts
CHANGED