Browse Source

support map option in stream

v4
Mathias Buus 8 years ago
parent
commit
b73c194d9d
  1. 9
      query-stream.js

9
query-stream.js

@ -45,6 +45,7 @@ function QueryStream (dht, query, opts) {
this._k = nodes ? Infinity : opts.k || 20 this._k = nodes ? Infinity : opts.k || 20
this._inflight = 0 this._inflight = 0
this._moveCloser = !nodes this._moveCloser = !nodes
this._map = opts.map || echo
this._bootstrapped = !this._moveCloser this._bootstrapped = !this._moveCloser
this._onresponse = onresponse this._onresponse = onresponse
this._onresponseholepunch = onresponseholepunch this._onresponseholepunch = onresponseholepunch
@ -164,14 +165,14 @@ QueryStream.prototype._callback = function (err, res, peer) {
return return
} }
this.push({ this.push(this._map({
node: { node: {
id: res.id, id: res.id,
port: peer.port, port: peer.port,
host: peer.host host: peer.host
}, },
value: res.value value: res.value
}) }))
} }
QueryStream.prototype._sendAll = function (nodes, force, useToken) { QueryStream.prototype._sendAll = function (nodes, force, useToken) {
@ -287,3 +288,7 @@ function copyNode (node) {
referrer: node.referrer || node.referer referrer: node.referrer || node.referer
} }
} }
function echo (a) {
return a
}

Loading…
Cancel
Save