import { Transform } from 'stream' ; export function createFilterStream < T > ( fn ) { return new Transform ( { objectMode : true , async transform ( obj , enc , done ) { const canPushDownStream = fn ( obj ) ; if ( canPushDownStream ) { this . push ( obj ) ; } done ( ) ; } , } ) ; }