hydra/src/main/workers/steam-games.worker.ts
2024-10-20 22:13:06 -03:00

17 lines
511 B
TypeScript

import type { SteamGame } from "@types";
import { slice } from "lodash-es";
import fs from "node:fs";
import { workerData } from "node:worker_threads";
const { steamGamesPath } = workerData;
const data = fs.readFileSync(steamGamesPath, "utf-8");
const steamGames = JSON.parse(data) as SteamGame[];
export const getById = (id: number) =>
steamGames.find((game) => game.id === id);
export const list = ({ limit, offset }: { limit: number; offset: number }) =>
slice(steamGames, offset, offset + limit);