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

Function filterBy

packages/db-ivm/src/operators/filterBy.ts:13–30  ·  view source on GitHub ↗
(
  other: IStreamBuilder<KeyValue<K, unknown>>,
)

Source from the content-addressed store, hash-verified

11 * @param other - The other stream to filter by, which must have the same key type as the input stream
12 */
13export function filterBy<
14 K,
15 V1 extends T extends KeyValue<infer _KT, infer VT> ? VT : never,
16 T,
17>(
18 other: IStreamBuilder<KeyValue<K, unknown>>,
19): PipedOperator<T, KeyValue<K, V1>> {
20 return (stream: IStreamBuilder<T>): IStreamBuilder<KeyValue<K, V1>> => {
21 const otherKeys = other.pipe(
22 map(([key, _]) => [key, null] as KeyValue<K, null>),
23 )
24 return stream.pipe(
25 innerJoin(otherKeys),
26 map(([key, [value, _]]) => [key, value] as KeyValue<K, V1>),
27 consolidate(),
28 )
29 }
30}

Callers 1

filterBy.test.tsFile · 0.50

Calls 4

mapFunction · 0.85
innerJoinFunction · 0.85
consolidateFunction · 0.85
pipeMethod · 0.80

Tested by

no test coverage detected