toastflow-core 0.0.2 → 0.0.4

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 +3 -1
  2. package/src/store.ts +7 -16
package/package.json CHANGED
@@ -1,6 +1,8 @@
1
1
  {
2
2
  "name": "toastflow-core",
3
- "version": "0.0.2",
3
+ "author": "adrianjanocko",
4
+ "license": "MIT",
5
+ "version": "0.0.4",
4
6
  "main": "src/index.ts",
5
7
  "module": "src/index.ts",
6
8
  "types": "src/index.ts",
package/src/store.ts CHANGED
@@ -673,27 +673,18 @@ function pickOverflowToast(
673
673
  return null;
674
674
  }
675
675
 
676
- const [first, ...rest] = samePos;
676
+ const first = samePos[0];
677
677
  if (!first) {
678
678
  return null;
679
679
  }
680
680
 
681
681
  if (order === "newest") {
682
- let oldest = first;
683
- for (const t of rest) {
684
- if (t.createdAt < oldest.createdAt) {
685
- oldest = t;
686
- }
687
- }
688
- return oldest;
689
- }
690
-
691
- let newest = first;
692
- for (const t of rest) {
693
- if (t.createdAt > newest.createdAt) {
694
- newest = t;
695
- }
682
+ return samePos.slice(1).reduce((oldest, toast) => {
683
+ return toast.createdAt < oldest.createdAt ? toast : oldest;
684
+ }, first);
696
685
  }
697
686
 
698
- return newest;
687
+ return samePos.slice(1).reduce((newest, toast) => {
688
+ return toast.createdAt > newest.createdAt ? toast : newest;
689
+ }, first);
699
690
  }