Skip to content

Commit 54bd783

Browse files
committed
feat: use fast-sort
1 parent 5312354 commit 54bd783

3 files changed

Lines changed: 7 additions & 8 deletions

File tree

bun.lock

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

data-loader.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { readFile } from "node:fs/promises";
22
import { homedir } from "node:os";
33
import path from "node:path";
4+
import { sort } from "fast-sort";
45
import { glob } from "tinyglobby";
56
import * as v from "valibot";
67

@@ -132,11 +133,7 @@ export async function loadUsageData(
132133
}
133134

134135
// Sort by date descending
135-
return results.sort((a, b) => {
136-
const dateA = new Date(a.date);
137-
const dateB = new Date(b.date);
138-
return dateB.getTime() - dateA.getTime();
139-
});
136+
return sort(results).desc((item) => new Date(item.date).getTime());
140137
}
141138

142139
export async function loadSessionData(
@@ -227,7 +224,5 @@ export async function loadSessionData(
227224
}
228225

229226
// Sort by total cost descending
230-
return results.sort((a, b) => {
231-
return b.totalCost - a.totalCost;
232-
});
227+
return sort(results).desc((item) => item.totalCost);
233228
}

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
"clean-pkg-json": "^1.3.0",
4141
"cli-table3": "^0.6.5",
4242
"consola": "^3.4.2",
43+
"fast-sort": "^3.4.1",
4344
"gunshi": "^0.25.0",
4445
"lint-staged": "^15.5.0",
4546
"picocolors": "^1.1.1",

0 commit comments

Comments
 (0)