diff --git a/lib/streams.js b/lib/streams.js index 5db2f13..5ac7e9a 100644 --- a/lib/streams.js +++ b/lib/streams.js @@ -237,8 +237,7 @@ function transform(input, process = () => undefined, finish = () => undefined, q } const result1 = process(input); const result2 = finish(); - if (result1 !== undefined && result2 !== undefined) return concat([result1, result2]); - return result1 !== undefined ? result1 : result2; + return concat([result1, result2].filter(result => result !== undefined)); } /** @@ -263,8 +262,7 @@ async function transformAsync( } const result1 = await process(input); const result2 = await finish(); - if (result1 !== undefined && result2 !== undefined) return concat([result1, result2]); - return result1 !== undefined ? result1 : result2; + return concat([result1, result2].filter(result => result !== undefined)); } function _transformStream(input, process, finish, queuingStrategy) {