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

Method getIterator

packages/db-ivm/src/indexes.ts:246–269  ·  view source on GitHub ↗

* This method returns an iterator over all values for a given key. * @param key - The key to get the values for. * @returns An iterator of value tuples [value, multiplicity].

(key: TKey)

Source from the content-addressed store, hash-verified

244 * @returns An iterator of value tuples [value, multiplicity].
245 */
246 *getIterator(key: TKey): Iterable<[TValue, number]> {
247 const mapOrSingleValue = this.#inner.get(key)
248 if (isSingleValue(mapOrSingleValue)) {
249 yield mapOrSingleValue
250 } else if (mapOrSingleValue === undefined) {
251 return
252 } else if (mapOrSingleValue instanceof ValueMap) {
253 // Direct ValueMap - all values have NO_PREFIX
254 for (const valueTuple of mapOrSingleValue.values()) {
255 yield valueTuple
256 }
257 } else {
258 // PrefixMap - iterate through all prefixes
259 for (const singleValueOrValueMap of mapOrSingleValue.values()) {
260 if (isSingleValue(singleValueOrValueMap)) {
261 yield singleValueOrValueMap
262 } else {
263 for (const valueTuple of singleValueOrValueMap.values()) {
264 yield valueTuple
265 }
266 }
267 }
268 }
269 }
270
271 /**
272 * This returns an iterator that iterates over all key-value pairs.

Callers 5

getMethod · 0.95
entriesMethod · 0.95
entriesIteratorsMethod · 0.95
emitLeftOuterResultsMethod · 0.80
emitRightOuterResultsMethod · 0.80

Calls 3

isSingleValueFunction · 0.85
getMethod · 0.45
valuesMethod · 0.45

Tested by

no test coverage detected