JavaScript Examples

JavaScriptOct 23, 2026

printAlignedCliTableRows

Formats arrays of records as an aligned plain-text table with calculated widths and optional right alignment, ready for terminal output.

formattingtableterminalclistdout
000
JavaScriptOct 23, 2026

encodeDecodeBase64Strictly

Encodes strings or byte arrays as Base64 and strictly validates decoding, rejecting malformed padding and non-canonical input.

bytesbuffervalidationencodingbase64
000
JavaScriptOct 23, 2026

validateInputFieldsWithRules

Validates required fields, numeric ranges, emails, and custom patterns, returning a flat map of readable field-level errors.

inputerrorsvalidationforms
000
JavaScriptOct 23, 2026

buildAndParseUrlQueryStrings

Builds query strings from defaults and overrides, then parses full URLs, paths, or raw queries with repeated keys returned as arrays.

query-stringurlurlsearchparamsencoding
000
JavaScriptOct 23, 2026

parseJsonWithSourceContext

Parses JSON text or a UTF-8 file and enriches V8 syntax errors with the source plus line and column details whenever V8 provides them.

parsingfileserrorsjsondiagnostics
000
JavaScriptOct 23, 2026

runBoundedWorkerPool

Executes zero-argument async task functions with a fixed concurrency limit, preserving input order while capturing each task's value or error.

concurrencyasyncworker-pooltasks
000
JavaScriptOct 23, 2026

fetchJsonWithTimeoutSignal

Fetches and parses JSON with Node's global fetch, aborting slow requests and reporting HTTP or parse failures with useful context.

httpjsontimeoutfetch
000
JavaScriptOct 23, 2026

loadEnvConfigWithSchema

Reads configuration from environment variables using a small schema, applying defaults and throwing one combined error naming every invalid field.

environmentconfignodevalidation
000
JavaScriptOct 23, 2026

burstFriendlyTokenBucketLimiter

Enforces an average request rate while permitting short bursts up to the bucket capacity, with an async acquire method for callers.

token-bucketasyncrate-limitthrottle
000
JavaScriptOct 23, 2026

boundedLruCacheWithMapRecency

Keeps a fixed-size cache in insertion order, promoting hits and writes to the front and evicting the least recently used key.

evictionlrucachemap
000
JavaScriptOct 23, 2026

multiKeyComparatorWithNullsLast

Creates a stable multi-key comparator for records, supporting per-key direction, numeric and date values, and nullish values sorted last.

sortingrecordsnull-handlingcomparator
000
JavaScriptOct 23, 2026

asyncChunkIterableBySize

Splits any sync or async iterable into fixed-size arrays, making batched API calls and paginated processing straightforward.

chunkingasync-iteratorsbatchespaginationiterables
000
JavaScriptOct 23, 2026

readFileLinesWithReadline

Streams a text file as an async line iterator using node:readline, so even large files stay usable without loading everything into memory.

async-iteratorsstreamsfilesreadline
000
JavaScriptOct 23, 2026

retryAsyncWithJitteredBackoff

Retries a failing async operation with capped exponential backoff and full jitter, so bursts of retries do not stampede a recovering service.

asyncresiliencebackoffretryjitter
000
JavaScriptOct 23, 2026

deepCloneAndMergeNestedData

Clones nested plain objects, arrays, Maps, and Sets without sharing references, then recursively merges overrides for safe configuration layering.

mapsmergeimmutabilitycloneobjects
000