Choose TypeScript, Go, Rust or C++ and find syntax, everyday APIs, standard libraries and tools in one place.
Scope and conventions
TypeScript/Node, Go 1.23+, Rust 2024 and C++23: from a first CLI to files, JSON, HTTP, concurrency and testing. Complete programs are labeled; other examples identify their surrounding code/imports. Optional libraries and version requirements are named in each entry.
console.log appends a newline. stdout.write writes the supplied text without adding one. String converts to text; JSON.stringify quotes/escapes a string as JSON.
Fragment
Complete Node module.
main.ts
Follow appearance
✓GitHub Light
GitHub Dark
Rosé Pine
Catppuccin Mocha
VS Code Dark+
import { stdout } from "node:process";console.log("north");stdout.write(JSON.stringify("a\tb"));
toFixed chooses decimal places and returns text. padStart pads text to a minimum length without truncating longer text. These operations can round or pad; they do not change the original number.
Fragment
Independent formatting fragments.
main.ts
Follow appearance
✓GitHub Light
GitHub Dark
Rosé Pine
Catppuccin Mocha
VS Code Dark+
const price = (6.2).toFixed(1);const tag = "x".padStart(4, ".");
readline produces lines without their endings. crlfDelay: Infinity treats CRLF as one ending even when delayed. Async iteration waits for each available line.
Fragment
Complete Node module.
main.ts
Follow appearance
✓GitHub Light
GitHub Dark
Rosé Pine
Catppuccin Mocha
VS Code Dark+
import { createInterface } from "node:readline";import { stdin } from "node:process";async function show() { const lines = createInterface({ input: stdin, crlfDelay: Infinity }); for await (const line of lines) { console.log(line); }}void show();
Number converts a whole string using JavaScript numeric syntax; blank/whitespace becomes zero and invalid text becomes NaN. parseInt can accept a numeric prefix. isInteger tests the resulting number.
Fragment
Independent conversion fragment; no lab policy.
main.ts
Follow appearance
✓GitHub Light
GitHub Dark
Rosé Pine
Catppuccin Mocha
VS Code Dark+
const value = Number("24");const failed = Number.isNaN(value);const whole = Number.isInteger(value);
setEncoding makes stdin yield decoded strings. Stream blocks are not guaranteed to be lines. A decoder/line accumulator must preserve partial records across chunks.
Fragment
Complete program; observes sizes, assembles no lines.
main.ts
Follow appearance
✓GitHub Light
GitHub Dark
Rosé Pine
Catppuccin Mocha
VS Code Dark+
import { stdin } from "node:process";async function sizes() { stdin.setEncoding("utf8"); for await (const block of stdin) { console.log(String(block).length); }}void sizes();