@naturalcycles/js-lib 14.241.2 → 14.241.3

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.
@@ -601,8 +601,6 @@ class LocalTimeFactory {
601
601
  * Returns null if invalid
602
602
  */
603
603
  parseOrNull(d) {
604
- if (!d)
605
- return null;
606
604
  if (d instanceof LocalTime)
607
605
  return d;
608
606
  let date;
@@ -612,6 +610,10 @@ class LocalTimeFactory {
612
610
  else if (typeof d === 'number') {
613
611
  date = new Date(d * 1000);
614
612
  }
613
+ else if (!d) {
614
+ // This check is after checking the number, to support `0`
615
+ return null;
616
+ }
615
617
  else if (typeof d !== 'string') {
616
618
  // unexpected type, e.g Function or something
617
619
  return null;
@@ -596,8 +596,6 @@ class LocalTimeFactory {
596
596
  * Returns null if invalid
597
597
  */
598
598
  parseOrNull(d) {
599
- if (!d)
600
- return null;
601
599
  if (d instanceof LocalTime)
602
600
  return d;
603
601
  let date;
@@ -607,6 +605,10 @@ class LocalTimeFactory {
607
605
  else if (typeof d === 'number') {
608
606
  date = new Date(d * 1000);
609
607
  }
608
+ else if (!d) {
609
+ // This check is after checking the number, to support `0`
610
+ return null;
611
+ }
610
612
  else if (typeof d !== 'string') {
611
613
  // unexpected type, e.g Function or something
612
614
  return null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@naturalcycles/js-lib",
3
- "version": "14.241.2",
3
+ "version": "14.241.3",
4
4
  "scripts": {
5
5
  "prepare": "husky",
6
6
  "build-prod": "build-prod-esm-cjs",
@@ -714,7 +714,6 @@ class LocalTimeFactory {
714
714
  * Returns null if invalid
715
715
  */
716
716
  parseOrNull(d: LocalTimeInputNullable): LocalTime | null {
717
- if (!d) return null
718
717
  if (d instanceof LocalTime) return d
719
718
 
720
719
  let date
@@ -723,6 +722,9 @@ class LocalTimeFactory {
723
722
  date = d
724
723
  } else if (typeof d === 'number') {
725
724
  date = new Date(d * 1000)
725
+ } else if (!d) {
726
+ // This check is after checking the number, to support `0`
727
+ return null
726
728
  } else if (typeof (d as any) !== 'string') {
727
729
  // unexpected type, e.g Function or something
728
730
  return null