jsonRead.ts
utils/jsonRead.ts
No strong subsystem tag
17
Lines
657
Bytes
1
Exports
0
Imports
10
Keywords
What this is
This page documents one file from the repository and includes its full source so you can read it without leaving the docs site.
Beginner explanation
This file is one piece of the larger system. Its name, directory, imports, and exports show where it fits. Start by reading the exports and related files first.
How it is used
Start from the exports list and related files. Those are the easiest clues for where this file fits into the system.
Expert explanation
Architecturally, this file intersects with general runtime concerns. It contains 17 lines, 0 detected imports, and 1 detected exports.
Important relationships
Detected exports
stripBOM
Keywords
jsoncontentstripbomleafsettingsutf-8utf8_bomextractedbreaktypes
Detected imports
- No import paths detected.
Source notes
This page embeds the full file contents. Small or leaf files are still indexed honestly instead of being over-explained.
Full source
/**
* 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
}