@@ -5,36 +5,34 @@ import type { DifferenceStreamReader } from "../graph.js"
5
5
import type { MultiSet } from "../multiset.js"
6
6
7
7
/**
8
- * Operator that applies a function to each element in the input stream
8
+ * Operator that applies a function to each multi-set in the input stream
9
9
*/
10
10
export class TapOperator < T > extends LinearUnaryOperator < T , T > {
11
- #f: ( data : T ) => void
11
+ #f: ( data : MultiSet < T > ) => void
12
12
13
13
constructor (
14
14
id : number ,
15
15
inputA : DifferenceStreamReader < T > ,
16
16
output : DifferenceStreamWriter < T > ,
17
- f : ( data : T ) => void
17
+ f : ( data : MultiSet < T > ) => void
18
18
) {
19
19
super ( id , inputA , output )
20
20
this . #f = f
21
21
}
22
22
23
23
inner ( collection : MultiSet < T > ) : MultiSet < T > {
24
- return collection . map ( ( data ) => {
25
- this . #f( data )
26
- return data
27
- } )
24
+ this . #f( collection )
25
+ return collection
28
26
}
29
27
}
30
28
31
29
/**
32
- * Invokes a function for each element in the input stream.
30
+ * Invokes a function for each multi-set in the input stream.
33
31
* This operator doesn't modify the stream and is used to perform side effects.
34
- * @param f - The function to invoke on each element
32
+ * @param f - The function to invoke on each multi-set
35
33
* @returns The input stream
36
34
*/
37
- export function tap < T > ( f : ( data : T ) => void ) : PipedOperator < T , T > {
35
+ export function tap < T > ( f : ( data : MultiSet < T > ) => void ) : PipedOperator < T , T > {
38
36
return ( stream : IStreamBuilder < T > ) : IStreamBuilder < T > => {
39
37
const output = new StreamBuilder < T > (
40
38
stream . graph ,
0 commit comments