MCPcopy Index your code
hub / github.com/node-modules/utility / writeJSONSync

Function writeJSONSync

src/json.ts:27–34  ·  view source on GitHub ↗
(filepath: string, content: string | object, options: JSONStringifyOptions = {})

Source from the content-addressed store, hash-verified

25}
26
27export function writeJSONSync(filepath: string, content: string | object, options: JSONStringifyOptions = {}) {
28 options.space = options.space ?? 2;
29 if (typeof content === 'object') {
30 content = JSON.stringify(content, options.replacer, options.space) + '\n';
31 }
32 mkdirSync(dirname(filepath), { recursive: true });
33 writeFileSync(filepath, content);
34}
35
36export async function readJSON<T = any>(filepath: string): Promise<T> {
37 const content = await readFile(filepath, 'utf8');

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…