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

use apply calling done #1

Open
tunnckoCore opened this issue Jun 27, 2015 · 0 comments
Open

use apply calling done #1

tunnckoCore opened this issue Jun 27, 2015 · 0 comments

Comments

@tunnckoCore
Copy link
Member

If promise returns array, it should pass every element of this array to different callback argument.
e.g.

function thunk (a, b) {
  return function (cb) {
    if (a === b) {
      return cb(new Error('a === b'))
    }
    cb(null, a, b, 3)
  }
}

var thunk2promise = require('thunk2promise')
var promise2thunk = require('promise2thunk')

var promise = thunk2promise(thunk(123, 456)).then(function (res) {
  console.log(res) //=> [1, 2, 3]
  return res
})

var thunk = promise2thunk(promise)

// currently it pass [1, 2, 3] array as second argument
thunk(function (err, one, two, three) {
  console.log(one, two, three) //=> 1, 2, 3
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant