stream#pipeline JavaScript Examples
The following examples show how to use
stream#pipeline.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: compress.js From ucompress with ISC License | 6 votes |
br = (source, mode) => new Promise((res, rej) => {
const dest = source + '.br';
stat(source, (err, stats) => {
/* istanbul ignore next */
if (err) rej(err);
else pipeline(
createReadStream(source),
createBrotliCompress({
[BROTLI_PARAM_SIZE_HINT]: stats.size,
[BROTLI_PARAM_QUALITY]: BROTLI_MAX_QUALITY,
[BROTLI_PARAM_MODE]: mode == 'text' ?
BROTLI_MODE_TEXT : (
mode === 'font' ?
BROTLI_MODE_FONT :
/* istanbul ignore next */
BROTLI_MODE_GENERIC
)
}),
createWriteStream(dest),
err => {
/* istanbul ignore next */
if (err) rej(err);
else res(dest);
}
);
});
})
Example #2
Source File: compress.js From ucompress with ISC License | 6 votes |
deflate = source => new Promise((res, rej) => {
const dest = source + '.deflate';
pipeline(
createReadStream(source),
createDeflate(zlibDefaultOptions),
createWriteStream(dest),
err => {
/* istanbul ignore next */
if (err) rej(err);
else res(dest);
}
);
})
Example #3
Source File: compress.js From ucompress with ISC License | 6 votes |
gzip = source => new Promise((res, rej) => {
const dest = source + '.gzip';
pipeline(
createReadStream(source),
createGzip(zlibDefaultOptions),
createWriteStream(dest),
err => {
/* istanbul ignore next */
if (err) rej(err);
else res(dest);
}
);
})
Example #4
Source File: index.js From kit with MIT License | 5 votes |
pipe = promisify(pipeline)
Example #5
Source File: index.js From kit with MIT License | 5 votes |
pipe = promisify(pipeline)