π― Use case
This file lives under βutils/β, which covers cross-cutting helpers (shell, tempfiles, settings, messages, process input, β¦). On the API surface it exposes stripBOM β mainly functions, hooks, or classes. What the file header says: Leaf stripBOM β extracted from json.ts to break settings β json β log β types/logs β β¦ β settings. json.ts imports this for its memoized+logging safeParseJSON; leaf callers that can't import json.ts use stripBOM + jsonParse inline (syncCacheState does this). UTF-8 BOM (U+FEFF): P.
Generated from folder role, exports, dependency roots, and inline comments β not hand-reviewed for every path.
π§ Inline summary
Leaf stripBOM β extracted from json.ts to break settings β json β log β types/logs β β¦ β settings. json.ts imports this for its memoized+logging safeParseJSON; leaf callers that can't import json.ts use stripBOM + jsonParse inline (syncCacheState does this). UTF-8 BOM (U+FEFF): PowerShell 5.x writes UTF-8 with BOM by default (Out-File, Set-Content). We can't control user environments, so strip on read. Without this, JSON.parse fails with "Unexpected token".
π€ Exports (heuristic)
stripBOM
π₯οΈ Source preview
/**
* Leaf stripBOM β extracted from json.ts to break settings β json β log β
* types/logs β β¦ β settings. json.ts imports this for its memoized+logging
* safeParseJSON; leaf callers that can't import json.ts use stripBOM +
* jsonParse inline (syncCacheState does this).
*
* UTF-8 BOM (U+FEFF): PowerShell 5.x writes UTF-8 with BOM by default
* (Out-File, Set-Content). We can't control user environments, so strip on
* read. Without this, JSON.parse fails with "Unexpected token".
*/
const UTF8_BOM = '\uFEFF'
export function stripBOM(content: string): string {
return content.startsWith(UTF8_BOM) ? content.slice(1) : content
}