Created
May 3, 2019 00:49
-
-
Save ortense/473ce323d066fe608d99783965b0b17b to your computer and use it in GitHub Desktop.
Example of node stream API V3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { promisify } from 'util' | |
import { pipeline } from 'stream' | |
import { createGzip } from 'zlib' | |
import { createReadStream, createWriteStream } from 'fs' | |
console.time('processing time') | |
promisify(pipeline)( | |
createReadStream('./big-file.iso'), | |
createGzip(), | |
createWriteStream('./big-file.tar.gz')) | |
.then(() => console.log('Done!')) | |
.catch(console.error) | |
.finally(() => console.timeEnd('processing time')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment