javascript-collections-framework
    Preparing search index...

    Documentation

    User documentation for javascript-collections-framework. Every export, with its signature, cost and examples, is in the API reference.

    Pre-release: pages are added here as each collection ships.

    • Coming from native JavaScript — Array, Map, Set, sorted arrays, shift queues, hand-written heaps and the Map LRU trick, each next to its collection, with what it costs and when to keep the native one
    • Open the playground in StackBlitz — try the package in the browser, without installing it
    • Recipes — short runnable programs for common tasks (top k, merging sorted arrays, sliding windows, an LRU cache, bookings, grid paths, running medians, time ranges), each with its collection and time complexity, runnable in StackBlitz
    • Behaviour notes — the behaviours that most often surprise newcomers: absence and throwing reads, delete vs removeAt, set vs put, live and fail-fast iteration, identity equality, views, sort() order
    • Compatibility — supported runtimes, frameworks, TypeScript versions and ways to load the package
    • Errors — the error classes, when each is thrown, catching, subclassing, and two copies of the package
    • Performance — the minified and gzipped size each export adds to a bundle, and the size budget each is held to
    • How this library is tested — contract suites, reference comparisons, scale, deep random runs, the built package, what covers each collection, what is not tested, and how to replay a failing seed
    • Versioning — what is public, what may change in which release, deprecation, and the policy before 1.0
    • Ordering — natural order, comparators and their helpers, compareSymbol for your own types
    • Collections: the shared contract — the Collection interface, live and fail-fast iteration, cursors, revision, printing
    • Equality and hashing — SameValueZero by default, the key option, equivalences, the equalsSymbol/hashCodeSymbol protocol
    • Using collections with frameworks — React, Vue, Svelte and other recipes, revision as a change signal, sending collections through JSON and workers, proxies, threads and await
    • Sets and maps together — equality and hashes across implementations, map views as sets, putAll from any map, native Set/Map interop, newSetFromMap for an LRU set or a set in a custom order
    • Lists and ArrayList — indexed lists, insert vs add, sorting, list cursors, subList and reversed views, differences from Array

    • Sets and HashSet — a drop-in for Set with value equality on request (key, equivalence), structural equals, live iteration, cost and collision resistance, differences from Set

    • Linked hash sets and LinkedHashSet — a set in insertion order with both ends: getFirst/getLast, removeFirst/removeLast, addFirst/addLast that insert or move, a live reversed view, live iteration with moves, differences from Set

    • Maps and HashMap — a drop-in for Map with keys compared by value on request, getOrInsert, compute and merge, live key, entry and value views, structural equals, cost, differences from Map

    • Linked hash maps and LinkedHashMap — a map in insertion or access order with both ends: firstEntry/lastEntry, polls, putFirst/putLast that insert or move, a live reversed view, an LRU cache from accessOrder, maxSize and onEvict, live iteration with moves and accesses, differences from Map

    • Queues, deques and ArrayDeque — first in first out, stacks with push/pop, both ends, the reversed view, null rejection, differences from Array

    • LinkedList and node handles — a deque with O(1) insert and remove next to a known element, handles, stored null/undefined, differences from Array

    • Sorted maps and TreeMap — mappings kept in key order, nearest-entry queries (floorEntry, ceilingEntry, …), key-only queries through keySet(), live range and reversed views, entries as live handles, failures that change nothing, differences from Map

    • Sorted sets and TreeSet — members kept in order, nearest-match queries (floor, ceiling, …), live range and reversed views, comparator sameness, failures that change nothing, differences from a sorted array

    • Immutable lists, sets and maps — listOf, setOf, mapOf and the copyOf… factories, duplicates and null as in Set/Map, value-keyed copies, what immutable covers, views, equality with other collections, differences from Object.freeze

    • Unmodifiable views and lists over arrays — read-only windows that show the owner's changes (unmodifiableList, unmodifiableSortedMap, …), what they refuse, live entries, access order, equality and type checks; asList over an array: write-through, direct changes and their limits, frozen arrays, differences from Array

    • Algorithms — binary search and insertion points, reverse, rotate, seeded shuffle, swap, fill, min/max over any iterable, frequency, disjoint, sub-list search; iterators stay valid; differences from Array

    • Priority queues and PriorityQueue — least element first in O(log n), comparators, iteration is not sorted, ties, failures that change nothing, differences from a sorted array

    Still to come: see the planned list in the README.