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

Method fromMultiSets

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

* Create an Index from multiple MultiSet messages. * @param messages - Array of MultiSet messages to build the index from. * @returns A new Index containing all the data from the messages.

(messages: Array<MultiSet<[K, V]>>)

Source from the content-addressed store, hash-verified

162 * @returns A new Index containing all the data from the messages.
163 */
164 static fromMultiSets<K, V>(messages: Array<MultiSet<[K, V]>>): Index<K, V> {
165 const index = new Index<K, V>()
166
167 for (const message of messages) {
168 for (const [item, multiplicity] of message.getInner()) {
169 const [key, value] = item
170 index.addValue(key, [value, multiplicity])
171 }
172 }
173
174 return index
175 }
176
177 /**
178 * This method returns a string representation of the index.

Callers 1

runMethod · 0.80

Calls 2

addValueMethod · 0.95
getInnerMethod · 0.80

Tested by

no test coverage detected