Skip to content

Instantly share code, notes, and snippets.

@slikts
Created December 22, 2019 15:42
Show Gist options
  • Save slikts/4c50addbec74975fd8606d78b9a3be5c to your computer and use it in GitHub Desktop.
Save slikts/4c50addbec74975fd8606d78b9a3be5c to your computer and use it in GitHub Desktop.
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