Remove duplicates from an array
Deduplicate primitives with a Set, or objects by a key or computed value, keeping the first occurrence.
Browser and Node.js utilities, async patterns and DOM helpers.
Loading snippets…
29 snippets
Deduplicate primitives with a Set, or objects by a key or computed value, keeping the first occurrence.
Shorten text to a maximum length without cutting in the middle of a word or a Unicode character.
Sort objects by one field, then break ties with another, with ascending or descending order per field.
Convert any title into a lowercase, hyphenated, accent-free slug that is safe to use in a URL.
Pause an async function for a number of milliseconds, with optional cancellation through AbortSignal.
Publish and subscribe to named events in about 15 lines, with an unsubscribe function returned from on().
Create UUIDs, random integers in a range and URL-safe tokens with the Web Crypto API instead of Math.random.
Process a large list with at most N promises in flight at once, preserving result order.
Build a new object with only some keys, or without some keys, without mutating the original.
Convert between query strings and objects with URLSearchParams, including repeated keys.
Wrap a function so it executes on the first call and returns the same result afterwards.
Cache results by argument so expensive pure functions only run once per distinct input.