Each module page also lists what it is not for, and where to go instead, including when a built-in Map, Set, or
array is the better answer.
Collections
- filter membership over millions of non-negative integer ids without paying a byte per possible idbitset
- combine two id sets by union, intersection, or difference without allocating a third setbitset
- ask how many ids are at or below a value or inside a range, which id is the k-th smallest, or which id comes next or beforebitset
- walk a set of ids in ascending order without sorting thembitset
- hold ids scattered across a wide range, such as row or document ids, without allocating the whole rangebitset
- keep the results of repeated lookups in memory without letting them grow past a fixed sizecache
- bound a store by total byte size or cost instead of by number of entriescache
- let stored results expire after a fixed time while the clock stays under test controlcache
- find out which entries were pushed out to make room, so they can be flushed or loggedcache
- switch the eviction policy for a given traffic shape without changing any call sitecache
- evict in an order of my own, such as by recompute cost or an assigned priority, while the cache keeps handling weights, expiry, and iterationcache
- take items out in the order they arrived without Array.prototype.shift turning the loop quadraticdeque
- add and remove items at both ends of a sequence, such as a breadth-first and depth-first hybriddeque
- keep only the last N values of a stream and learn which value just fell out, for a running sum or moving averagedeque
- hold a long numeric buffer in eight bytes per value with no per-element allocationdeque
- read the k-th item from either end of a queue without removing anythingdeque
- tell whether two items are already connected, while connections keep arriving one at a timedisjoint-set
- merge two groups of items into one, pair by pair, and count how many groups remaindisjoint-set
- run Kruskal's minimum spanning tree, or detect a cycle in an undirected graphdisjoint-set
- group a large collection of items into its connected componentsdisjoint-set
- drive percolation, image segmentation, or any equivalence relation that only ever grows by mergingdisjoint-set
- read the exact number of occurrences of a keyfrequency-table
- track repeated integer observations as items enter and leavefrequency-table
- sum frequencies between two bounds after updatesfrequency-table
- read a median or quantile by its position among all observationsfrequency-table
- repeatedly take the smallest or largest item from a changing collectionheap
- run Dijkstra, Prim, or A* with decrease-key on a keyed queueheap
- keep a running top-k over a stream, evicting the worst entry as it arrivesheap
- schedule tasks by priority and re-prioritize work that is already queuedheap
- drain a set in sorted order without sorting all of it firstheap
- find which SSTables' [minKey, maxKey] fence pointers can hold a key on a level-0 readinterval-index
- select every table in the next level whose key range overlaps a compaction inputinterval-index
- find every booking, lease, or time window that covers a moment or overlaps a spaninterval-index
- keep a set of ranges that are added and removed by id while answering overlap queriesinterval-index
- match ranges whose endpoints are byte strings, numbers, or any keys with a total orderinterval-index
- read the k-th smallest key while keys enter and leaveordered-map
- count keys at or below a boundordered-map
- find the nearest stored key at or above, or at or below, a probeordered-map
- iterate key-value entries in a sorted range, from a start key onward, or in descending orderordered-map
- buffer sorted writes in memory before flushing them in key order, as an LSM MemTable doesordered-map
- limit one client's request weight and tell it the least whole millisecond to wait before retryingrate-limit
- limit many clients without letting the per-client table grow with every client ever seenrate-limit
- choose a rate-limit algorithm by the most weight it admits in a trailing window rather than by its namerate-limit
- combine two limits for one client into one meter a keyed table accepts like a built-in kindrate-limit
- prove a limiter's worst case and its retry boundary by replaying the same arrival schedulesrate-limit
- read a set as it was at an earlier point, while it keeps changingsnapshot-set
- answer whether a value was present at a given moment, for an audit trail or a change logsnapshot-set
- serve MVCC reads: older readers keep their view while a writer mutatessnapshot-set
- keep an undo stack over membership, or time-travel debug a collection, without cloning it per stepsnapshot-set
- report when each value joined and left a live set, as of any snapshot taken earliersnapshot-set
- build the data or index block of a sorted string table from key-value pairs already in key ordersorted-block
- store many sorted Uint8Array keys that share long prefixes in fewer bytes than an array of pairssorted-block
- look up, seek to the first key at or above a bound, or scan a key range in a block built oncesorted-block
- persist a sorted run as bytes and reload it with every offset, varint, and key order validatedsorted-block
- trade block size against lookup cost by choosing how often a key is stored wholesorted-block
- read only the first few items across several already-sorted inputssorted-merge
- merge sorted runs or posting lists with one buffered item per inputsorted-merge
- combine sorted streams with deterministic ordering for equal itemssorted-merge
- merge sorted async streams, such as remote SSTable block reads, without buffering whole inputssorted-merge
Search and text
- look up all records tagged with an exact key after reading the input onceinverted-index
- visit records carrying any requested tag once, in their original orderinverted-index
- group record positions by feature when a record can supply several features or repeat oneinverted-index
- fetch up to a fixed number of autocomplete candidates from a static vocabularyprefix-index
- expand the last query token into matching terms before an exact posting queryprefix-index
- list identifiers or paths starting with a string without scanning all keysprefix-index
- rank documents matching any of a set of exact tokensterm-index
- restrict ranked search to eligible document IDs without changing corpus statisticsterm-index
- read term counts per document and document frequencies without scanning the corpusterm-index
- find the longest known key that prefixes a query, such as a tool slug or a route segmenttrie
- resolve a dotted path, package name, or header name against a catalog built oncetrie
- fall back from a specific entry to a broader one, including an empty default keytrie
- look up a known set of token sequences by prefix without slicing and re-joining candidatestrie
Graphs and optimization
- count permutations or unordered combinations exactlycombinatorics
- compute Stirling numbers for permutations by cycle count and partitions by block countcombinatorics
- compute Bell numbers to count all set partitionscombinatorics
- evaluate log-factorials and log binomial coefficients for large inputscombinatorics
- share repeated subexpressions even when their operands were built from different equivalent termse-graph
- recognize that replacing an operand with an equal operand preserves an expressione-graph
- select the cheapest equivalent expression under a caller's operator pricese-graph
- find a good route or schedule where improving one position at a time gets stuckevolution
- keep the best candidate seen across generations while a whole population changesevolution
- select parents in proportion to rank, then recombine two orderings into one child orderingevolution
- run an optimizer deterministically from a seed so a recorded run replays exactlyevolution
- decide when to stop from a stagnation count instead of a fixed generation budgetevolution
- mutate or cross a permutation without touching the array the caller handed inevolution
- find the fewest-hops route between two points or the cheapest routes to selected destinations, all reachable points, or between every pair on a small graphgraph
- order tasks, builds, or courses so every dependency comes first, or find the cycle that makes that impossiblegraph
- count the islands or connected pieces of a map, a grid, or a network, and say which piece each item is ingraph
- decide whether one item can reach another, and list the steps of the path between themgraph
- ask who depends on an item and what it depends on, with in-degree and out-degreegraph
- store a graph from an edge list as compact typed arrays, and persist it as bytesgraph
Randomness and statistics
- rank vector differences by coordinate magnitude or angledistance
- measure the extra information cost of approximating one probability distribution with anotherdistance
- bound how much any event probability can change between two probability distributionsdistance
- compute exact set overlap or set distancedistance
- look up which direction to rank a comparison and whether it is symmetric or follows the triangle inequalitydistance
- compute probability below a threshold in a named distributiondistribution
- find a quantile for a distributiondistribution
- draw values from an injected source according to a distributiondistribution
- summarize observed numbers with a mean, variance, quantile, histogram, or correlationdistribution
- compute a chi-square p-value for observed counts against category probabilitieshypothesis-test
- test whether draws fit a continuous distribution with Kolmogorov-Smirnovhypothesis-test
- compare the distributions of two sampleshypothesis-test
- test one sample mean, two sample means, or paired measurements with a t-test, or three or more group means with a one-way ANOVA, or compare samples by rank with Mann-Whitney U, Wilcoxon signed-rank, or Kruskal-Wallishypothesis-test
- test an observed success count using an exact binomial p-valuehypothesis-test
- calculate a two-sided or directional Fisher exact p-value for a 2-by-2 tablehypothesis-test
- replay the same random sequence from a seed in tests, simulations, or procedural generationprng
- roll an unbiased integer in 1..n without modulo biasprng
- draw unsigned 64-bit values larger than 2^53 without losing precision or capping the boundprng
- give parallel workers non-overlapping subsequences of one sequenceprng
- produce the same random values in a browser, in Node.js, and in Bunprng
- pick k distinct items from a population or an index range without shuffling the whole populationsampling
- shuffle a copy of a list reproducibly, so a rerun from the same seed yields the same ordersampling
- pick one item in proportion to its weight, or k items in proportion to their weights without replacementsampling
- keep a bounded uniform sample of a stream whose length is not known in advancesampling
- pick two distinct items, optionally at least a minimum number of positions apartsampling
- replay a simulation or a generated test fixture exactly from a recorded seedsampling
- count distinct visitors without storing every visitorscalar-sketch
- check whether an id or URL was already processed, with a small false-positive rate and no false negativesscalar-sketch
- find the heavy hitters of a stream without keeping a counter per keyscalar-sketch
- estimate how much two large sets overlap without holding both of themscalar-sketch
- answer those questions per partition and merge the answers afterwardsscalar-sketch
- keep the answer in a fixed-size summary that is serialized now and queried laterscalar-sketch
- skip a disk or network read for a key that an immutable table or file certainly does not holdstatic-filter
- check membership in a set of byte keys that is known in full before the first query and never changesstatic-filter
- keep a membership test for millions of keys in the smallest memory a Worker or browser tab can sparestatic-filter
- ship a compact membership summary beside an SSTable, a static index, or a release artifact and reload it laterstatic-filter
- pick between a 0.39% and a 0.0015% false-positive rate at 9 to 10 or 18 to 20 bits per keystatic-filter
Serialization and utilities
- store the same artifact once no matter how many callers write itcas
- prove that the bytes a store returned are the content a key namescas
- share artifacts between processes that do not share a filesystemcas
- keep serialized structures in an object store, a browser cache, or a Map behind one interfacecas
- catch a failure from any Knotkit package without importing each package's own error classeserrors
- read which package failed, which category, and the exact code from a caught errorerrors
- recognize a Knotkit error that crossed a realm or came from a duplicate copy of a package, where instanceof reports a false negativeerrors
- format an unknown thrown value into a message without a hostile toString replacing the caller's errorerrors
- fail a decode on the first invalid element using the throwing package's own error class and codeerrors
- fingerprint bytes, text, or an unsigned integer the same way in every browser, Node.js, and Bun runtimehash
- shard keys across buckets or deduplicate records by a cheap fingerprinthash
- hash table keys without allocating or retaining a copy of the inputhash
- reproduce earlier digests in a later process from a persisted algorithm version and seedhash
- hash a large payload chunk by chunk without holding it all in memoryhash
- build a composite key such as (user id, timestamp) that a byte-ordered store sorts field by fieldkey-encoding
- sort one field of a composite key descending, such as newest version first, without a custom comparatorkey-encoding
- store signed integers or doubles as keys that sort numerically rather than by their raw byteskey-encoding
- scan every key that starts with a prefix by computing the range's exclusive upper boundkey-encoding
- compare or sort Uint8Array keys in the order memcmp, LevelDB, or IndexedDB useskey-encoding
- encode a package-identified binary artifact with validated section geometrywire
- declare a module's binary artifact once so every decoder runs the same prelude and raises the same codeswire
- encode generic values with an injected byte codecwire
- prove an element codec injective over a run before emitting an artifactwire
- share bounded little-endian wire primitives across data-structure packageswire
- hand closure state to a package serializer without widening its public interfacewire
Nothing matches. Try fewer words, or browse all modules.
Agents can do the same lookup offline: the installed package includes node_modules/knotkit/capabilities.json, and the
knotkit-select skill reads it for them.