Skip to content

wallacegibbon/pipeasync

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Introduction

The pipe method in Node.js is pretty convenient to use. But it is based on events. To use it along with async function, you need to listen to specific events and do some wraps to return a Promise Object.

This package provide a function that wraps necessary things, you only need to know the stop event.

For normal file, the stop event is 'finish'. For unzip, the stop event is 'close'.

e.g.

async function test() {
  const a = fs.createReadStream('a.txt')
  const b = fs.createWriteStream('b.txt')
  await pipeasync(a, b, 'finish')

  const c = fs.createReadStream('c.zip')
  const d = unzip.Extract({ path: './d' })
  await pipeasync(c, d, 'close')
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published