function next (err, doc) { if(err) return cb(err) //read a singe value from the stream. pull( chooser(doc, vrange, opts), pull.find(Boolean, cb) ) }
paramap(function (user, cb) { pull( sbot.createHistoryStream({id: user.id, limit: 1}), pull.find(null, function (err, msg) { if (err) throw err user.first = msg.value.timestamp user.lifespan = user.last - user.first cb(null, user) }) ) }),
paramap(function (data, cb) { // DONT use this, because our .first will be using the msg's declared timestamp, and this is the msg's local receive time // if(data.ts) return cb(null, { id: data.id, last: data.ts }) // handle some legacy: older users may not have .ts included in latest() pull( sbot.createHistoryStream({id: data.id, sequence: data.sequence - 1}), pull.find(null, function (err, msg) { if (err) throw err if (msg == null) return cb(null) cb(null, { id: data.id, last: msg.value.timestamp }) }) ) }),
function first(stream, cb) { pull(stream, pull.find(cb)) }