7 snippets · production-ready JavaScript & TypeScript
A collection of TypeScript sliding window algorithm implementations for common array and string processing tasks, optimized for O(n) time complexity.
A comprehensive collection of generic binary search variants in TypeScript, including classic binary search, lower bound, upper bound, and search range functions with support for custom comparators.
A generic TypeScript function that splits an array into smaller arrays (chunks) of a specified size, with proper handling for all edge cases.
A generic TypeScript function that groups array elements by a computed key, returning a Record<string, T[]> where each key maps to an array of matching elements.
A generic TypeScript function that removes duplicate elements from an array based on a custom key selector function, preserving the first occurrence of each unique key.
A fully type-safe TypeScript function that recursively flattens deeply nested arrays of arbitrary depth, preserving the element type through advanced conditional type inference.
A type-safe TypeScript function that zips multiple arrays together into tuples, similar to Python's zip(). Handles arrays of different lengths by stopping at the shortest one.