Skip to content

armgit / TREK

Public Imported from GitHub
0

The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.

429 B
Raw Blame
import fs from 'node:fs';

/**
 * Read + parse a JSON file, tolerating a UTF-8 BOM (0xFEFF) — Windows editors
 * love to add one, and a bare JSON.parse then fails with a cryptic
 * "Unexpected token" that points at an invisible character.
 */
export function readJsonFile<T = unknown>(p: string): T {
  const text = fs.readFileSync(p, 'utf8');
  return JSON.parse(text.codePointAt(0) === 0xfeff ? text.slice(1) : text) as T;
}