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

Method constructor

packages/db-ivm/src/operators/count.ts:11–25  ·  view source on GitHub ↗
(
    id: number,
    inputA: DifferenceStreamReader<[K, V]>,
    output: DifferenceStreamWriter<[K, number]>,
  )

Source from the content-addressed store, hash-verified

9 */
10export class CountOperator<K, V> extends ReduceOperator<K, V, number> {
11 constructor(
12 id: number,
13 inputA: DifferenceStreamReader<[K, V]>,
14 output: DifferenceStreamWriter<[K, number]>,
15 ) {
16 const countInner = (vals: Array<[V, number]>): Array<[number, number]> => {
17 let totalCount = 0
18 for (const [_, diff] of vals) {
19 totalCount += diff
20 }
21 return [[totalCount, 1]]
22 }
23
24 super(id, inputA, output, countInner)
25 }
26}
27
28/**

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected