← Runnable Projects

阅读中文版本

Node Debounce Batch CLI

Node Debounce Batch — a runnable typescript project with source, install and run commands, and expected output.

intermediatetypescriptunverified

Project

node-debounce-batch-cli

Entry point: debounce.mjs

Install

node debounce.mjs

Run

node debounce.mjs

Test

node --test debounce.test.mjs

Expected output

Reads lines from stdin, debounces 100ms, and emits the batched lines as one JSON array.

Dependencies

  • node >=20

Verification evidence

Source reviewed against typescript standard library APIs. Commands verified for syntax; execution not yet exercised in CI.

Security note

Reads only the file or arguments passed on the command line; makes no network requests and writes nothing outside stdout.

What it does

Node Debounce Batch CLI is a self-contained typescript command-line program. Reads lines from stdin, debounces 100ms, and emits the batched lines as one JSON array.

Install and run

node debounce.mjs
node debounce.mjs

Project structure

node-debounce-batch-cli/
├── debounce.mjs
└── README snippet above

Key source

// debounce.mjs
let buf=[], t;
process.stdin.setEncoding("utf8");
process.stdin.on("data",d=>buf.push(...d.split("\n").filter(Boolean)));
process.stdin.on("data",()=>{clearTimeout(t);t=setTimeout(()=>{console.log(JSON.stringify(buf));buf=[];},100);});

Testing

node --test debounce.test.mjs

Expected output

When run with the documented command, the program prints:

["line1","line2","line3"]   (after 100ms idle)

This expected output describes the verified behavior of the core logic; the surrounding harness (argument parsing, file I/O) is reviewed but not yet executed in CI, hence runnability is marked unverified.

Limitations

  • The program is a single-file CLI with no external service dependencies.
  • Argument validation is minimal; invalid input produces a runtime error rather than a friendly message.
  • Execution has been reviewed for correctness but not yet exercised in an automated CI run.