Examples

Page 11 of 14

rustSnippet

Generic RAII Object Pool

Reuse expensive objects through a mutex-backed pool whose guard returns the item automatically on drop, with a factory fallback.

rustSnippet

JoinSet Task Supervisor

Spawn a batch of async tasks, collect results as they finish, and abort everything still running when a deadline expires.

typescriptSnippet

Fixed-Size Circular Buffer

Store the most recent items in a fixed-capacity circular buffer with overwrite eviction, indexed access, iteration, and clearing.

typescriptSnippet

CSRF Double-Submit Token

Issue HMAC-bound CSRF tokens and verify that the header, cookie and session agree before accepting a state change.

typescriptSnippet

Dotenv File Parser

Parse .env files with comments, export prefixes, quoted values, escapes and multiline strings without mutating process.env.

typescriptSnippet

Glob Pattern Matcher

Compile glob patterns with star, globstar, question marks, character classes and braces into anchored regular expressions.