Javascript Examples

Page 8 of 9

Browse Javascript examples

javascriptSnippet

Levenshtein Edit Distance

Compute the minimum number of insertions, deletions, and substitutions between two strings, the basis of fuzzy matching and spell suggestions.

javascriptSnippet

LRU Cache With Map Ordering

Implement a least-recently-used cache that evicts the oldest entry when capacity is exceeded, reusing Map insertion order to track recency.

javascriptSnippet

Memoize With a Time to Live

Cache a function's result by argument key with an expiry, so expensive pure calls are reused briefly and stale values eventually recompute.

javascriptSnippet

Diff Two Flat Objects

Compare two flat objects field by field and report added, removed, and changed keys, the core of audit logging and change detection.

javascriptSnippet

Paginate an In-Memory Array

Slice an array into a page and return metadata such as total pages and whether more results follow, the shape most list endpoints expose.

javascriptSnippet

Bounded Concurrency Promise Pool

Run an array of async tasks with a maximum concurrency, so a large batch does not open all connections at once and overwhelm a downstream service.

javascriptSnippet

Throttle a Function

Throttle limits how often a function runs by allowing at most one call per interval, useful for scroll and resize handlers that fire continuously.

javascriptSnippet

Async Mutex With FIFO Waiters

Serialize critical sections with an async mutex that queues waiters in FIFO order, supports acquisition timeouts and safe double release.

javascriptSnippet

Cookie Header Parser

Parse a Cookie request header into a null-prototype object, handling quoted values, duplicates and RFC 6265 rules.