node-modules/await-stream-ready

Name: await-stream-ready

Owner: node_modules

Description: a promise waiting stream ready

Created: 2017-03-24 16:31:09.0

Updated: 2018-05-14 05:28:04.0

Pushed: 2017-03-27 07:27:02.0

Homepage: null

Size: 10

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

await-stream-ready

A promise waiting stream ready

NPM version build status Test coverage David deps Known Vulnerabilities NPM download


Usage
i await-stream-ready --save

Wait a read stream

t fs = require('fs');
t awaitReadStream = require('await-stream-ready').read;

c function read(file) {
nst stream = fs.createReadStream(file);
ream.on('data', buf => {
// consume buf
;
ait awaitReadStream(stream);

Or wait a write stream

t fs = require('fs');
t awaitWriteStream = require('await-stream-ready').write;

c function write(srcStream, file) {
nst stream = srcStream.pipe(fs.createWriteStream(file));
ait awaitWriteStream(stream);

It will switch the readable stream to flowing mode automatically.

License

MIT


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.