refactor(pkgs): share vitest config and dedupe helpers (#3384)

This commit is contained in:
Hampus authored and GitHub committed 2026-10-10 23:23:34 +02:00
1 parent 5695510980
commit 575a5adbef
43 files changed
+172 -874

No files matched your search

+7 -12
View File
@@ -16,7 +16,11 @@ function toClampedTimestamp(timestamp: number): number {
}
export function extractTimestamp(snowflake: string): number {
return extractTimestampFromSnowflake(snowflake);
try {
return extractTimestampWithEpoch(BigInt(snowflake), FLUXER_EPOCH);
} catch (_error) {
return Number.NaN;
}
}
export function extractTimestampBigInt(snowflake: bigint): number {
@@ -86,17 +90,8 @@ export function age(snowflake: string): number {
return Date.now() - timestamp;
}
export function extractTimestampFromSnowflake(snowflake: string, epoch?: string | bigint): number {
try {
const epochBigInt = epoch != null ? (typeof epoch === 'string' ? BigInt(epoch) : epoch) : FLUXER_EPOCH;
return extractTimestampWithEpoch(BigInt(snowflake), epochBigInt);
} catch (_error) {
return Number.NaN;
}
}
export function extractTimestampFromSnowflakeAsDate(snowflake: string, epoch?: string | bigint): Date {
const timestamp = extractTimestampFromSnowflake(snowflake, epoch);
export function extractTimestampFromSnowflakeAsDate(snowflake: string): Date {
const timestamp = extractTimestamp(snowflake);
if (Number.isNaN(timestamp)) {
return new Date();
}