JavaScript Examples
printAlignedCliTableRows
Formats arrays of records as an aligned plain-text table with calculated widths and optional right alignment, ready for terminal output.
encodeDecodeBase64Strictly
Encodes strings or byte arrays as Base64 and strictly validates decoding, rejecting malformed padding and non-canonical input.
validateInputFieldsWithRules
Validates required fields, numeric ranges, emails, and custom patterns, returning a flat map of readable field-level errors.
buildAndParseUrlQueryStrings
Builds query strings from defaults and overrides, then parses full URLs, paths, or raw queries with repeated keys returned as arrays.
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.
runBoundedWorkerPool
Executes zero-argument async task functions with a fixed concurrency limit, preserving input order while capturing each task's value or error.
fetchJsonWithTimeoutSignal
Fetches and parses JSON with Node's global fetch, aborting slow requests and reporting HTTP or parse failures with useful context.
loadEnvConfigWithSchema
Reads configuration from environment variables using a small schema, applying defaults and throwing one combined error naming every invalid field.
burstFriendlyTokenBucketLimiter
Enforces an average request rate while permitting short bursts up to the bucket capacity, with an async acquire method for callers.
boundedLruCacheWithMapRecency
Keeps a fixed-size cache in insertion order, promoting hits and writes to the front and evicting the least recently used key.
multiKeyComparatorWithNullsLast
Creates a stable multi-key comparator for records, supporting per-key direction, numeric and date values, and nullish values sorted last.
asyncChunkIterableBySize
Splits any sync or async iterable into fixed-size arrays, making batched API calls and paginated processing straightforward.
readFileLinesWithReadline
Streams a text file as an async line iterator using node:readline, so even large files stay usable without loading everything into memory.
retryAsyncWithJitteredBackoff
Retries a failing async operation with capped exponential backoff and full jitter, so bursts of retries do not stampede a recovering service.
deepCloneAndMergeNestedData
Clones nested plain objects, arrays, Maps, and Sets without sharing references, then recursively merges overrides for safe configuration layering.