await-write

1.0.0 • Public • Published

await-write

Await node writable's write() and end() methods as promises.

awaitWrite

awaitWrite(writeable,buffer)

  • writeable {stream.Writable}
  • buffer {Buffer}

The function returns when the writable object is drain.

awaitEnd

awaitEnd(writeable)

  • writeable {stream.Writable}

The function returns when the writable object is finished.

Example

const { awaitWrite, awaitEnd } = require("await-write")

// ...

try{
    await awaitWrite(writable,Buffer.from("hello "))
    await awaitWrite(writable,Buffer.from("world!"))
    await awaitEnd(writeable)
}catch(e){
    // handle error
}

Readme

Keywords

none

Package Sidebar

Install

npm i await-write

Weekly Downloads

1

Version

1.0.0

License

MIT

Unpacked Size

7.21 kB

Total Files

7

Last publish

Collaborators

  • didyhu