Javascript Examples

Page 7 of 9

Browse Javascript examples

javascriptSnippet

Async Read Write Lock

Implement a read-write lock allowing concurrent readers or a single writer with upgrade support for shared state.

javascriptSnippet

Async Timeout Wrapper

Race a promise against a timer so a slow dependency cannot hold a request open indefinitely, aborting the underlying signal when the deadline passes.

javascriptSnippet

Curry a Function

Curry a function so partial application returns a new function until every argument is supplied, enabling reusable configured variants.

javascriptSnippet

Debounce a Function

Debounce wraps a callback so it runs only after activity stops for a set wait, collapsing bursts of calls into a single trailing invocation.

javascriptSnippet

Deep Clone Plain Data Objects

Clone nested objects and arrays without sharing references, using the structured clone algorithm so dates, maps, and cycles are handled correctly.

javascriptSnippet

Minimal Typed Event Emitter

Build a small publish and subscribe emitter that registers listeners per event name and supports one-shot subscribers and clean removal.

javascriptSnippet

Group Array Items by Key

Group an array of records into a map keyed by one of their fields, a building block for reports, indexes, and bucketed aggregations.

javascriptSnippet

Decode JWT Claims and Check Expiry

Decode the payload of a JSON Web Token and verify that its expiry and not-before claims are respected, without trusting the token's signature blindly.