Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

return then-callback promise #5

Open
tunnckoCore opened this issue Jul 19, 2016 · 0 comments
Open

return then-callback promise #5

tunnckoCore opened this issue Jul 19, 2016 · 0 comments
Labels

Comments

@tunnckoCore
Copy link
Member

tunnckoCore commented Jul 19, 2016

Like that on L48-49-50

promise = utils.normalizePromise(resolved, promise)
return utils.then(promise)

to be even able to pass callback to the returned promise's .then method.

const fs = require('fs')
const hybridify = require('hybridify')
const readdir = hybridify.hybridify(fs.readdir)

// called two times
function callback (err, files) {
  if (err) return console.error('callback err:', err)
  console.log('callback res:', files) // => array with directory files
}

const promise = readdir('./', callback)
promise.then(callback)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant