@@ -179,39 +179,54 @@ class KadDHT {
179
179
* Times out after 1 minute.
180
180
*
181
181
* @param {Buffer } key
182
- * @param {number } [maxTimeout=60000] - optional timeout
182
+ * @param {Object } options - get options
183
+ * @param {number } options.maxTimeout - optional timeout (default: 60000)
183
184
* @param {function(Error, Buffer) } callback
184
185
* @returns {void }
185
186
*/
186
- get ( key , maxTimeout , callback ) {
187
- if ( typeof maxTimeout === 'function' ) {
188
- callback = maxTimeout
189
- maxTimeout = null
187
+ get ( key , options , callback ) {
188
+ if ( typeof options === 'function' ) {
189
+ callback = options
190
+ options = { }
191
+ } else if ( typeof options === 'number' ) { // This will be deprecated in a next release
192
+ options = {
193
+ maxTimeout : options
194
+ }
195
+ } else {
196
+ options = options || { }
190
197
}
191
198
192
- if ( maxTimeout == null ) {
193
- maxTimeout = c . minute
199
+ if ( ! options . maxTimeout ) {
200
+ options . maxTimeout = c . minute
194
201
}
195
202
196
- this . _get ( key , maxTimeout , callback )
203
+ this . _get ( key , options , callback )
197
204
}
198
205
199
206
/**
200
207
* Get the `n` values to the given key without sorting.
201
208
*
202
209
* @param {Buffer } key
203
210
* @param {number } nvals
204
- * @param {number } [maxTimeout=60000]
211
+ * @param {Object } options - get options
212
+ * @param {number } options.maxTimeout - optional timeout (default: 60000)
205
213
* @param {function(Error, Array<{from: PeerId, val: Buffer}>) } callback
206
214
* @returns {void }
207
215
*/
208
- getMany ( key , nvals , maxTimeout , callback ) {
209
- if ( typeof maxTimeout === 'function' ) {
210
- callback = maxTimeout
211
- maxTimeout = null
216
+ getMany ( key , nvals , options , callback ) {
217
+ if ( typeof options === 'function' ) {
218
+ callback = options
219
+ options = { }
220
+ } else if ( typeof options === 'number' ) { // This will be deprecated in a next release
221
+ options = {
222
+ maxTimeout : options
223
+ }
224
+ } else {
225
+ options = options || { }
212
226
}
213
- if ( maxTimeout == null ) {
214
- maxTimeout = c . minute
227
+
228
+ if ( ! options . maxTimeout ) {
229
+ options . maxTimeout = c . minute
215
230
}
216
231
217
232
this . _log ( 'getMany %b (%s)' , key , nvals )
@@ -274,7 +289,7 @@ class KadDHT {
274
289
} )
275
290
276
291
// run our query
277
- timeout ( ( cb ) => query . run ( rtp , cb ) , maxTimeout ) ( cb )
292
+ timeout ( ( cb ) => query . run ( rtp , cb ) , options . maxTimeout ) ( cb )
278
293
}
279
294
] , ( err ) => {
280
295
if ( err && vals . length === 0 ) {
0 commit comments