Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function modifyJSONC(text: string, path: jsonc.JSONPath, f: (oldValue: jsonc.Node | undefined) => any): any {
const old = jsonc.findNodeAtLocation(jsonc.parseTree(text), path)
return jsonc.applyEdits(
text,
jsoncEdit.setProperty(text, path, f(old), {
eol: '\n',
insertSpaces: true,
tabSize: 2,
})
)
}