Skip to content

Latest commit

 

History

History
27 lines (19 loc) · 401 Bytes

README.md

File metadata and controls

27 lines (19 loc) · 401 Bytes

await-callback

Wrap and await callback code

Usage

var promise = require('await-callback')
var fs = require('fs')

async function main () {
  var result = await promise(done => {
    fs.writeFile('hello', 'world', 'utf8', err => {
      if (err) return done(err)
      fs.readFile('hello', 'utf8', done)
    })
  })

  console.log(result) // 'world'
}

main()

License

Apache-2.0