toastflow-core 0.0.1 → 0.0.2

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/store.ts +9 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "toastflow-core",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "main": "src/index.ts",
5
5
  "module": "src/index.ts",
6
6
  "types": "src/index.ts",
package/src/store.ts CHANGED
@@ -673,9 +673,14 @@ function pickOverflowToast(
673
673
  return null;
674
674
  }
675
675
 
676
+ const [first, ...rest] = samePos;
677
+ if (!first) {
678
+ return null;
679
+ }
680
+
676
681
  if (order === "newest") {
677
- let oldest = samePos[0];
678
- for (const t of samePos) {
682
+ let oldest = first;
683
+ for (const t of rest) {
679
684
  if (t.createdAt < oldest.createdAt) {
680
685
  oldest = t;
681
686
  }
@@ -683,8 +688,8 @@ function pickOverflowToast(
683
688
  return oldest;
684
689
  }
685
690
 
686
- let newest = samePos[0];
687
- for (const t of samePos) {
691
+ let newest = first;
692
+ for (const t of rest) {
688
693
  if (t.createdAt > newest.createdAt) {
689
694
  newest = t;
690
695
  }