Last active
January 20, 2023 17:28
-
-
Save lmammino/f713e110c35503422177ac11765846b8 to your computer and use it in GitHub Desktop.
Session about Node.js streams with Kelvin
This file contains hidden or 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 { createReadStream, createWriteStream } from 'fs' | |
const source = createReadStream('./assets/moby-dick.txt') | |
const dest = createWriteStream('./assets/moby-dick-decompressed.txt') | |
source | |
.pipe(dest) |
This file contains hidden or 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 { createReadStream, createWriteStream } from 'fs' | |
import { createGunzip } from 'zlib' | |
const source = createReadStream('./assets/moby-dick.txt.gz') | |
const decompress = createGunzip() | |
const dest = createWriteStream('./assets/moby-dick-decompressed.txt') | |
source | |
.pipe(decompress) | |
.pipe(dest) |
This file contains hidden or 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 { createReadStream, createWriteStream } from 'fs' | |
import { createBrotliCompress, createGzip, createDeflate } from 'zlib' | |
const source = createReadStream('./assets/moby-dick.txt') | |
const destGzip = createWriteStream('./results/moby-dick.txt.gz') | |
const destBrotli = createWriteStream('./results/moby-dick.txt.br') | |
const destDeflate = createWriteStream('./results/moby-dick.txt.deflate') | |
const gzip = createGzip() | |
const brotli = createBrotliCompress() | |
const deflate = createDeflate() | |
source | |
.pipe(gzip) | |
.pipe(destGzip) | |
source | |
.pipe(brotli) | |
.pipe(destBrotli) | |
source | |
.pipe(deflate) | |
.pipe(destDeflate) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment