simplify tools imports

This commit is contained in:
Gavin McDonald
2025-07-04 14:18:38 -04:00
parent c6e316a1f8
commit b4b0c853f1
14 changed files with 29 additions and 26 deletions

View File

@@ -1,12 +1,12 @@
import { isHighCard, isLowCard } from '@/tools/cardTypes';
import { isHighCard, isLowCard } from '@/tools';
import { Layout, Settings, TarokkaGameCard } from '@/types';
export default function getTooltip(
export const getCardInfo = (
card: TarokkaGameCard,
position: Layout,
dm: boolean,
settings: Settings,
) {
) => {
const { card: cardName, description, flipped } = card;
let text: string[] = [];
@@ -39,4 +39,4 @@ export default function getTooltip(
}
return text;
}
};

View File

@@ -1,4 +1,4 @@
export default function getRandomItems<T>(items: T[], count: number): T[] {
export const getRandomItems = <T>(items: T[], count: number): T[] => {
const shuffled = [...items];
// Fisher-Yates shuffle
@@ -8,4 +8,4 @@ export default function getRandomItems<T>(items: T[], count: number): T[] {
}
return count > shuffled.length ? shuffled : shuffled.slice(0, count);
}
};

View File

@@ -1,8 +1,8 @@
import { cardStyles, standardMap } from '@/constants/tarokka';
import { Settings, TarokkaCard, TarokkaGameCard } from '@/types';
export default function getURL(card: TarokkaCard | TarokkaGameCard, settings: Settings) {
export const getURL = (card: TarokkaCard | TarokkaGameCard, settings: Settings) => {
const styleConfig = cardStyles[settings.cardStyle];
const fileBase = settings.cardStyle === 'standard' ? standardMap[card.id] : card.id;
return `${styleConfig.baseURL}${fileBase}${card.extension || styleConfig.extension}`;
}
};

View File

@@ -1,4 +1,11 @@
export * from '@/tools/cardTypes';
export * from '@/tools/getCardInfo';
export * from '@/tools/getRandomItems';
export * from '@/tools/getURL';
export * from '@/tools/log';
export * from '@/tools/omit';
export * from '@/tools/parseMilliseconds';
export * from '@/tools/reduceTilts';
export * from '@/tools/simpleID';
export * from '@/tools/throttle';
export * from '@/tools/validTilt';

View File

@@ -1,7 +1,7 @@
export default function omit<T extends Record<string, any>>(
export const omit = <T extends Record<string, any>>(
obj: T,
propToRemove: keyof T,
): Omit<T, typeof propToRemove> {
): Omit<T, typeof propToRemove> => {
const { [propToRemove]: _, ...rest } = obj;
return rest;
}
};

View File

@@ -7,7 +7,7 @@ export interface ParsedMilliseconds {
seconds: number;
}
export default function parseMilliseconds(timestamp: number): ParsedMilliseconds {
export const parseMilliseconds = (timestamp: number): ParsedMilliseconds => {
const days = Math.floor(timestamp / DAY);
timestamp %= DAY;
@@ -21,4 +21,4 @@ export default function parseMilliseconds(timestamp: number): ParsedMilliseconds
timestamp %= SECOND;
return { days, hours, minutes, seconds };
}
};

View File

@@ -1,9 +1,7 @@
import getRandomItems from '@/tools/getRandomItems';
import { getRandomItems } from '@/tools';
const alphabet = '0123456789abcdefghijklmnopqrstuvwxyz';
const generateID = (length: number = 6) => {
export const generateID = (length: number = 6) => {
return getRandomItems(alphabet.split(''), length).join('');
};
export default generateID;