@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.
@@ -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[];
@@ -46,6 +46,8 @@ class LocalDate {
46
46
  * Returns null if invalid.
47
47
  */
48
48
  static parseOrNull(d) {
49
+ if (!d)
50
+ return null;
49
51
  if (d instanceof LocalDate)
50
52
  return d;
51
53
  // todo: explore more performant options
@@ -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;
@@ -48,6 +48,8 @@ class LocalTime {
48
48
  * Returns null if invalid
49
49
  */
50
50
  static parseOrNull(d) {
51
+ if (!d)
52
+ return null;
51
53
  if (d instanceof LocalTime)
52
54
  return d;
53
55
  let date;
@@ -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(+opt.maxWait || 0, wait) : opt.maxWait;
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 = [];
@@ -43,6 +43,8 @@ export class LocalDate {
43
43
  * Returns null if invalid.
44
44
  */
45
45
  static parseOrNull(d) {
46
+ if (!d)
47
+ return null;
46
48
  if (d instanceof LocalDate)
47
49
  return d;
48
50
  // todo: explore more performant options
@@ -45,6 +45,8 @@ export class LocalTime {
45
45
  * Returns null if invalid
46
46
  */
47
47
  static parseOrNull(d) {
48
+ if (!d)
49
+ return null;
48
50
  if (d instanceof LocalTime)
49
51
  return d;
50
52
  let date;
@@ -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(+opt.maxWait || 0, wait) : opt.maxWait;
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@naturalcycles/js-lib",
3
- "version": "14.95.0",
3
+ "version": "14.95.1",
4
4
  "scripts": {
5
5
  "prepare": "husky install",
6
6
  "build-prod": "build-prod-esm-cjs",
@@ -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(+opt.maxWait! || 0, wait) : opt.maxWait
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[] = []