Audit a JSON list of key=value assignments without printing their values. This is a local data check under the documented conventions; it does not execute tools or contact a service.
Before you start
- Save the code as recipe.cjs and run node recipe.cjs using Node.js 22, supplying the JSON document through stdin. No CLI arguments or help option are accepted.
- Only node:fs is loaded, and its only operation is bounded readSync calls on stdin descriptor 0. The CLI does not open input paths, write files, execute external commands or contact a network.
- Input must be a JSON array containing at most 100 strings. Each string must contain an equals sign; the first equals sign separates the key from the value.
- Keys contain 1–64 ASCII characters: an ASCII letter followed by ASCII letters, digits or underscores. Matching is full-string, including rejection of a final newline. Keys are case-sensitive and are not trimmed or normalized.
- Empty values and additional equals signs in values are allowed. Values are never included in output or diagnostics.
- Successful processing exits 0 and emits exactly one JSON object, followed by a newline, with no stderr. The repeated array contains only keys occurring at least twice, sorted by ASCII key, with ascending one-based positions.
- Invalid arguments, invalid input and stdin read failures exit 2, emit no stdout and use the generic lowercase stderr diagnostic error: invalid request.
Build and check
- Use Node.js 22 CommonJS. Save the code as recipe.cjs.
- Save the supplied JSON example as input.json, encoded as UTF-8 without a BOM.
- Run: node recipe.cjs < input.json
- Compare the output with the expected result; handle exit code 2 as invalid input.
Limits to understand
- The CLI reads at most 65537 bytes and rejects input exceeding 65536 bytes. It can reject oversized input without waiting for EOF.
- UTF-8 decoding is strict. TextDecoder uses fatal:true and ignoreBOM:true, preserving a leading BOM so JSON.parse rejects it. Native JSON.parse semantics apply.
- The parsed input is held in memory alongside the byte buffer, decoded text and grouping data. Memory use includes runtime and parser overhead, not just the input byte count.
- Stdin may block while waiting for data or EOF.
- Successful output reveals repeated key names and their positions, which may be sensitive even though assignment values are excluded.
- This does not parse shell syntax, expand variables or load an environment.
- Output-write failures are excluded from the exit-status, stdout and stderr guarantees.
Run it
node recipe.cjs < input.jsonExample input
["TOKEN=secret", "HOST=local", "TOKEN=other"]Expected output
{"repeated": [{"key": "TOKEN", "positions": [1, 3]}]}
