I'd like to use a method (from jsonist) with the following structure:
jsonist.get(uri, options, callback)
uri
and options
are needed (options for passing a certain header)
However I'm not certain that Highland's wrapCallback can handle the two options here (minus the callback)
const H = require('highland')
const req = H.wrapCallback(jsonist.get)
req(uri, options).apply(H.log)
With this the stream is logged, not the data
Is there a better way to do this?
You can either specify the params inside wrapCallback
:
const req = H.wrapCallback((uri, options, cb) => get(uri, options, cb))
req('some.uri', { options })
Or you could use a generator directly if the callback has artiy > 2:
const req = (uri, options) => H(push => {
get(uri, options, (err, res, body) => {
push(err, body)
push(null, h.nil)
})
})
req('some.uri', { options })