Download packages/coding-agent/src/utils/json.ts from SaylorTwift/pi: direct link, hf CLI and curl.
- Browser
- Download file 341 Bytes
-
https://huggingface.co/SaylorTwift/pi/resolve/main/packages/coding-agent/src/utils/json.ts
- Command line
-
hf download hf://SaylorTwift/pi/packages/coding-agent/src/utils/json.ts
-
curl -L -o json.ts https://huggingface.co/SaylorTwift/pi/resolve/main/packages/coding-agent/src/utils/json.ts
341 Bytes
| /** Strip `//` line comments and trailing commas from JSON, leaving string literals untouched. */ | |
| export function stripJsonComments(input: string): string { | |
| return input | |
| .replace(/"(?:\\.|[^"\\])*"|\/\/[^\n]*/g, (m) => (m[0] === '"' ? m : "")) | |
| .replace(/"(?:\\.|[^"\\])*"|,(\s*[}\]])/g, (m, tail) => tail ?? (m[0] === '"' ? m : "")); | |
| } | |