Node Ring Buffer CLI
Node Ring Buffer — a runnable typescript project with source, install and run commands, and expected output.
Project
node-ring-buffer-cli
Entry point: ring.mjs
Install
node ring.mjsRun
node ring.mjsTest
node --test ring.test.mjsExpected output
Fixed-capacity ring buffer; pushes 5 items into a size-3 buffer and prints the retained items.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 Ring Buffer CLI is a self-contained typescript command-line program. Fixed-capacity ring buffer; pushes 5 items into a size-3 buffer and prints the retained items.
Install and run
node ring.mjs
node ring.mjs
Project structure
node-ring-buffer-cli/
├── ring.mjs
└── README snippet above
Key source
// ring.mjs
class Ring{constructor(n){this.n=n;this.a=[];}push(v){this.a.push(v);if(this.a.length>this.n)this.a.shift();}values(){return this.a;}}
const r=new Ring(3);for(let i=1;i<=5;i++)r.push(i);
console.log(r.values().join(","));
Testing
node --test ring.test.mjs
Expected output
When run with the documented command, the program prints:
3,4,5 (oldest evicted)
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.