Skip to content

Instantly share code, notes, and snippets.

@slikts
Created December 22, 2019 15:42
Embed
What would you like to do?
export const mapStream = <A, B>(f: (a: A) => B, source: Readable) =>
source.pipe(
new Transform({
objectMode: true,
transform: (chunk, _, callback) => {
callback(null, f(chunk));
}
})
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment