(f: (data: T) => boolean)
| 30 | * @param f - The predicate to filter elements |
| 31 | */ |
| 32 | export function filter<T>(f: (data: T) => boolean): PipedOperator<T, T> { |
| 33 | return (stream: IStreamBuilder<T>): IStreamBuilder<T> => { |
| 34 | const output = new StreamBuilder<T>( |
| 35 | stream.graph, |
| 36 | new DifferenceStreamWriter<T>(), |
| 37 | ) |
| 38 | const operator = new FilterOperator<T>( |
| 39 | stream.graph.getNextOperatorId(), |
| 40 | stream.connectReader(), |
| 41 | output.writer, |
| 42 | f, |
| 43 | ) |
| 44 | stream.graph.addOperator(operator) |
| 45 | return output |
| 46 | } |
| 47 | } |
no test coverage detected