0no-co / wonka

🎩 A tiny but capable push & pull stream library for TypeScript and Flow
MIT License
709 stars 29 forks source link

fix: Add missing filter overload to allow for type narrowing #149

Closed kitten closed 1 year ago

kitten commented 1 year ago

Resolves #148

This adds a missing overload for filter which will allow us to narrow types, e.g. by applying type conditions. We can now specify narrowing types and still get the desired output without casting:


pipe(
  fromArray([false, true, false, true]),
  filter((x): x is true => !!x),
  forEach(console.log), // always true
);