@@ -5,36 +5,34 @@ import type { DifferenceStreamReader } from "../graph.js"
55import type { MultiSet } from "../multiset.js"
66
77/**
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
99 */
1010export class TapOperator < T > extends LinearUnaryOperator < T , T > {
11- #f: ( data : T ) => void
11+ #f: ( data : MultiSet < T > ) => void
1212
1313 constructor (
1414 id : number ,
1515 inputA : DifferenceStreamReader < T > ,
1616 output : DifferenceStreamWriter < T > ,
17- f : ( data : T ) => void
17+ f : ( data : MultiSet < T > ) => void
1818 ) {
1919 super ( id , inputA , output )
2020 this . #f = f
2121 }
2222
2323 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
2826 }
2927}
3028
3129/**
32- * Invokes a function for each element in the input stream.
30+ * Invokes a function for each multi-set in the input stream.
3331 * 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
3533 * @returns The input stream
3634 */
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 > {
3836 return ( stream : IStreamBuilder < T > ) : IStreamBuilder < T > => {
3937 const output = new StreamBuilder < T > (
4038 stream . graph ,
0 commit comments