Mapping Specific Types in an Effect Stream

When using stream, is there a handy way to map only on emissions that match a certain condition, so lets say my Stream can emit type {done : true, name : string} or {done : false}, and I want to map only the one that satisfies done: true... Obviously I can do a regular map with an if in it and return the object if it doesn't satisfy, but I find the typing of this can be a bit verbose in some cases for some of my helper functions... is there a way to say something like:

stream.pipe(Stream.mapOnly(({done}) => done === true, ({name} /* automatically type narrowed */) => /* ... map ... */)


Filter works but I believe filter will remove all the non-done ones, and I want to let those pass thru
Was this page helpful?