diff --git a/mod.ts b/mod.ts index 18faa9f..c2c0eb8 100644 --- a/mod.ts +++ b/mod.ts @@ -341,17 +341,16 @@ export function ifilter( /** * Apply map, and filter invalid results in the same pass. */ -export function imapfilter( +export function imapfilter( iterable: Iterable, - mapfunc: (_: T1) => Exclude | typeof exclusion, - exclusion: E = null as unknown as E, -): Iterable { + mapfunc: (_: T1) => T2 | null, +): Iterable> { return { [Symbol.iterator]: function* () { for (let value of iterable) { const mapped = mapfunc(value); - if (mapped !== exclusion) { - yield mapped as T2; + if (mapped !== null) { + yield mapped as Exclude; } } },