From 408ec63e2a6356f25103cfecf944ff7a72b7c1c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=92=D0=B8=D0=BA=D1=82=D0=BE=D1=80=20=D0=93=D1=83=D0=B1?= =?UTF-8?q?=D0=B0=D0=BD=D0=BE=D0=B2?= Date: Fri, 29 Oct 2021 08:40:43 +0300 Subject: [PATCH] Added the updateSpeed option in the 'websockets.depth()' method --- node-binance-api.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/node-binance-api.js b/node-binance-api.js index 3301ec2e..1f101d83 100644 --- a/node-binance-api.js +++ b/node-binance-api.js @@ -5530,20 +5530,21 @@ let api = function Binance( options = {} ) { * @param {function} callback - callback function * @return {string} the websocket endpoint */ - depth: function depth ( symbols, callback ) { + depth: function depth ( symbols, callback, opt = {} ) { let reconnect = () => { - if ( Binance.options.reconnect ) depth( symbols, callback ); + if ( Binance.options.reconnect ) depth( symbols, callback, opt ); }; let subscription; + let updateSpeed = (opt.updateSpeed || '100ms'); if ( Array.isArray( symbols ) ) { if ( !isArrayUnique( symbols ) ) throw Error( 'depth: "symbols" cannot contain duplicate elements.' ); let streams = symbols.map( function ( symbol ) { - return symbol.toLowerCase() + '@depth@100ms'; + return symbol.toLowerCase() + `@depth@${updateSpeed}`; } ); subscription = subscribeCombined( streams, callback, reconnect ); } else { let symbol = symbols; - subscription = subscribe( symbol.toLowerCase() + '@depth@100ms', callback, reconnect ); + subscription = subscribe( symbol.toLowerCase() + `@depth@${updateSpeed}`, callback, reconnect ); } return subscription.endpoint; },