MCPcopy Create free account
hub / github.com/TanStack/db / nextLowerPair

Method nextLowerPair

packages/db/src/utils/btree.ts:271–277  ·  view source on GitHub ↗

Returns the next pair whose key is smaller than the specified key (or undefined if there is none). * If key === undefined, this function returns the highest pair. * @param key The key to search for. * @param reusedArray Optional array used repeatedly to store key-value pairs, to *

(key: K | undefined, reusedArray?: [K, V])

Source from the content-addressed store, hash-verified

269 * avoid creating a new array each time you call this method.
270 */
271 nextLowerPair(key: K | undefined, reusedArray?: [K, V]): [K, V] | undefined {
272 reusedArray = reusedArray || ([] as unknown as [K, V])
273 if (key === undefined) {
274 return this._root.maxPair(reusedArray)
275 }
276 return this._root.getPairOrNextLower(key, this._compare, false, reusedArray)
277 }
278
279 /** Returns the next key smaller than the specified key, or undefined if there is none.
280 * Also, nextLowerKey(undefined) returns the highest key.

Callers 3

nextLowerKeyMethod · 0.95
nextPairMethod · 0.80
insertMethod · 0.80

Calls 2

maxPairMethod · 0.45
getPairOrNextLowerMethod · 0.45

Tested by

no test coverage detected