@hobenakicoffee/libraries 1.23.0 → 1.24.0
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.
package/package.json
CHANGED
package/src/types/supabase.ts
CHANGED
|
@@ -1597,6 +1597,7 @@ export type Database = {
|
|
|
1597
1597
|
p_from?: string;
|
|
1598
1598
|
p_limit?: number;
|
|
1599
1599
|
p_profile_id: string;
|
|
1600
|
+
p_search?: string;
|
|
1600
1601
|
p_status: Database["public"]["Enums"]["post_status_enum"];
|
|
1601
1602
|
p_to?: string;
|
|
1602
1603
|
};
|
|
@@ -1615,6 +1616,7 @@ export type Database = {
|
|
|
1615
1616
|
purchase_count: number;
|
|
1616
1617
|
revenue_total: number;
|
|
1617
1618
|
slug: string;
|
|
1619
|
+
subtitle: string;
|
|
1618
1620
|
tags: string[];
|
|
1619
1621
|
title: string;
|
|
1620
1622
|
updated_at: string;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { describe, expect, test } from "bun:test";
|
|
2
|
+
import { formatCount } from "./format-count";
|
|
3
|
+
|
|
4
|
+
describe("formatCount", () => {
|
|
5
|
+
test("formats numbers less than 1000 using formatNumber", () => {
|
|
6
|
+
expect(formatCount(0)).toBe("0");
|
|
7
|
+
expect(formatCount(999)).toBe("999");
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
test("formats numbers >= 1000 with k suffix", () => {
|
|
11
|
+
expect(formatCount(1000)).toBe("1k");
|
|
12
|
+
expect(formatCount(2000)).toBe("2k");
|
|
13
|
+
expect(formatCount(10_000)).toBe("10k");
|
|
14
|
+
expect(formatCount(1_000_000)).toBe("1000k");
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
test("shows decimal for non-round thousands", () => {
|
|
18
|
+
expect(formatCount(1500)).toBe("1.5k");
|
|
19
|
+
expect(formatCount(10_500)).toBe("10.5k");
|
|
20
|
+
});
|
|
21
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { formatNumber } from "./format-number";
|
|
2
|
+
|
|
3
|
+
export function formatCount(n: number) {
|
|
4
|
+
if (n >= 1000) {
|
|
5
|
+
const formatted = n / 1000;
|
|
6
|
+
return Number.isInteger(formatted)
|
|
7
|
+
? `${formatted}k`
|
|
8
|
+
: `${formatted.toFixed(1)}k`;
|
|
9
|
+
}
|
|
10
|
+
return formatNumber(n);
|
|
11
|
+
}
|