@naturalcycles/js-lib 14.95.0 → 14.95.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.
- package/dist/datetime/localDate.d.ts +2 -2
- package/dist/datetime/localDate.js +2 -0
- package/dist/datetime/localTime.d.ts +2 -2
- package/dist/datetime/localTime.js +2 -0
- package/dist/decorators/debounce.js +1 -1
- package/dist/string/safeJsonStringify.js +1 -1
- package/dist-esm/datetime/localDate.js +2 -0
- package/dist-esm/datetime/localTime.js +2 -0
- package/dist-esm/decorators/debounce.js +1 -1
- package/dist-esm/string/safeJsonStringify.js +1 -1
- package/package.json +1 -1
- package/src/datetime/localDate.ts +3 -2
- package/src/datetime/localTime.ts +3 -2
- package/src/decorators/debounce.ts +1 -1
- package/src/string/safeJsonStringify.ts +1 -1
|
@@ -24,8 +24,8 @@ export declare class LocalDate {
|
|
|
24
24
|
/**
|
|
25
25
|
* Returns null if invalid.
|
|
26
26
|
*/
|
|
27
|
-
static parseOrNull(d: LocalDateConfig): LocalDate | null;
|
|
28
|
-
static isValid(iso: string): boolean;
|
|
27
|
+
static parseOrNull(d: LocalDateConfig | undefined | null): LocalDate | null;
|
|
28
|
+
static isValid(iso: string | undefined | null): boolean;
|
|
29
29
|
static today(): LocalDate;
|
|
30
30
|
static todayUTC(): LocalDate;
|
|
31
31
|
static sort(items: LocalDate[], mutate?: boolean, descending?: boolean): LocalDate[];
|
|
@@ -27,8 +27,8 @@ export declare class LocalTime {
|
|
|
27
27
|
/**
|
|
28
28
|
* Returns null if invalid
|
|
29
29
|
*/
|
|
30
|
-
static parseOrNull(d: LocalTimeConfig): LocalTime | null;
|
|
31
|
-
static isValid(d: LocalTimeConfig): boolean;
|
|
30
|
+
static parseOrNull(d: LocalTimeConfig | undefined | null): LocalTime | null;
|
|
31
|
+
static isValid(d: LocalTimeConfig | undefined | null): boolean;
|
|
32
32
|
static now(): LocalTime;
|
|
33
33
|
static fromComponents(c: {
|
|
34
34
|
year: number;
|
|
@@ -10,7 +10,7 @@ function _debounce(func, wait, opt = {}) {
|
|
|
10
10
|
let lastInvokeTime = 0;
|
|
11
11
|
const maxing = 'maxWait' in opt;
|
|
12
12
|
const { leading = false, trailing = true } = opt;
|
|
13
|
-
const maxWait = maxing ? Math.max(
|
|
13
|
+
const maxWait = maxing ? Math.max(Number(opt.maxWait) || 0, wait) : opt.maxWait;
|
|
14
14
|
function invokeFunc(time) {
|
|
15
15
|
const args = lastArgs;
|
|
16
16
|
const thisArg = lastThis;
|
|
@@ -17,7 +17,7 @@ function _safeJsonStringify(obj, replacer, spaces, cycleReplacer) {
|
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
exports._safeJsonStringify = _safeJsonStringify;
|
|
20
|
-
/* eslint-disable @typescript-eslint/no-unused-expressions, no-bitwise */
|
|
20
|
+
/* eslint-disable @typescript-eslint/no-unused-expressions, no-bitwise, no-implicit-coercion */
|
|
21
21
|
function serializer(replacer, cycleReplacer) {
|
|
22
22
|
const stack = [];
|
|
23
23
|
const keys = [];
|
|
@@ -7,7 +7,7 @@ export function _debounce(func, wait, opt = {}) {
|
|
|
7
7
|
let lastInvokeTime = 0;
|
|
8
8
|
const maxing = 'maxWait' in opt;
|
|
9
9
|
const { leading = false, trailing = true } = opt;
|
|
10
|
-
const maxWait = maxing ? Math.max(
|
|
10
|
+
const maxWait = maxing ? Math.max(Number(opt.maxWait) || 0, wait) : opt.maxWait;
|
|
11
11
|
function invokeFunc(time) {
|
|
12
12
|
const args = lastArgs;
|
|
13
13
|
const thisArg = lastThis;
|
|
@@ -13,7 +13,7 @@ export function _safeJsonStringify(obj, replacer, spaces, cycleReplacer) {
|
|
|
13
13
|
return JSON.stringify(obj, serializer(replacer, cycleReplacer), spaces);
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
|
-
/* eslint-disable @typescript-eslint/no-unused-expressions, no-bitwise */
|
|
16
|
+
/* eslint-disable @typescript-eslint/no-unused-expressions, no-bitwise, no-implicit-coercion */
|
|
17
17
|
function serializer(replacer, cycleReplacer) {
|
|
18
18
|
const stack = [];
|
|
19
19
|
const keys = [];
|
package/package.json
CHANGED
|
@@ -55,7 +55,8 @@ export class LocalDate {
|
|
|
55
55
|
/**
|
|
56
56
|
* Returns null if invalid.
|
|
57
57
|
*/
|
|
58
|
-
static parseOrNull(d: LocalDateConfig): LocalDate | null {
|
|
58
|
+
static parseOrNull(d: LocalDateConfig | undefined | null): LocalDate | null {
|
|
59
|
+
if (!d) return null
|
|
59
60
|
if (d instanceof LocalDate) return d
|
|
60
61
|
|
|
61
62
|
// todo: explore more performant options
|
|
@@ -76,7 +77,7 @@ export class LocalDate {
|
|
|
76
77
|
return new LocalDate(year, month, day)
|
|
77
78
|
}
|
|
78
79
|
|
|
79
|
-
static isValid(iso: string): boolean {
|
|
80
|
+
static isValid(iso: string | undefined | null): boolean {
|
|
80
81
|
return this.parseOrNull(iso) !== null
|
|
81
82
|
}
|
|
82
83
|
|
|
@@ -63,7 +63,8 @@ export class LocalTime {
|
|
|
63
63
|
/**
|
|
64
64
|
* Returns null if invalid
|
|
65
65
|
*/
|
|
66
|
-
static parseOrNull(d: LocalTimeConfig): LocalTime | null {
|
|
66
|
+
static parseOrNull(d: LocalTimeConfig | undefined | null): LocalTime | null {
|
|
67
|
+
if (!d) return null
|
|
67
68
|
if (d instanceof LocalTime) return d
|
|
68
69
|
|
|
69
70
|
let date
|
|
@@ -89,7 +90,7 @@ export class LocalTime {
|
|
|
89
90
|
return new LocalTime(date, false)
|
|
90
91
|
}
|
|
91
92
|
|
|
92
|
-
static isValid(d: LocalTimeConfig): boolean {
|
|
93
|
+
static isValid(d: LocalTimeConfig | undefined | null): boolean {
|
|
93
94
|
return this.parseOrNull(d) !== null
|
|
94
95
|
}
|
|
95
96
|
|
|
@@ -49,7 +49,7 @@ export function _debounce<T extends AnyFunction>(
|
|
|
49
49
|
const maxing = 'maxWait' in opt
|
|
50
50
|
|
|
51
51
|
const { leading = false, trailing = true } = opt
|
|
52
|
-
const maxWait = maxing ? Math.max(
|
|
52
|
+
const maxWait = maxing ? Math.max(Number(opt.maxWait) || 0, wait) : opt.maxWait
|
|
53
53
|
|
|
54
54
|
function invokeFunc(time: number) {
|
|
55
55
|
const args = lastArgs
|
|
@@ -20,7 +20,7 @@ export function _safeJsonStringify(
|
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
/* eslint-disable @typescript-eslint/no-unused-expressions, no-bitwise */
|
|
23
|
+
/* eslint-disable @typescript-eslint/no-unused-expressions, no-bitwise, no-implicit-coercion */
|
|
24
24
|
|
|
25
25
|
function serializer(replacer?: Reviver, cycleReplacer?: Reviver): Reviver {
|
|
26
26
|
const stack: any[] = []
|