style: move randInRange to utils

This commit is contained in:
2026-06-19 04:05:38 -03:00
parent 4c76abc274
commit e11e2093b0
4 changed files with 19 additions and 21 deletions
+17 -12
View File
@@ -1,22 +1,27 @@
export type DLC = {
id: string;
name: string | null;
dlcIds: {
steam: string;
epic: string;
grdk: string;
};
id: string;
name: string | null;
dlcIds: {
steam: string;
epic: string;
grdk: string;
};
};
export const getFileName = (iconFilePath: string): string => {
const base = iconFilePath.split('/').pop() ?? '';
return base.split('.')[0];
const base = iconFilePath.split('/').pop() ?? '';
return base.split('.')[0];
};
export const cleanFolderName = (name: string): string =>
name.replace(/[\\/:*?"<>|]/g, '_');
name.replace(/[\\/:*?"<>|]/g, '_');
export const isKiller = (idx: number): boolean => idx >= 268435456;
export const isNamedDLC = (dlc: DLC): dlc is DLC & { name: string } =>
!!dlc.name && !dlc.name.startsWith('@');
export const isNamedDLC = (dlc: DLC): dlc is DLC & { name: string } => !!dlc.name && !dlc.name.startsWith('@');
export const randInRange = (min: number, max: number) => {
const lo = Math.min(min, max);
const hi = Math.max(min, max);
return Math.floor(Math.random() * (hi - lo + 1)) + lo;
};