From bc0018064a4c3380ced574766798e3f422b78cb9 Mon Sep 17 00:00:00 2001 From: doppelgunner Date: Sun, 28 May 2023 05:51:02 +0800 Subject: [PATCH] fix: use JSONBig.parse to parse websocket message instead of JSON.parse to not drop numbers that exceeds javascript max number digits limit. --- node-binance-api.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/node-binance-api.js b/node-binance-api.js index a672d77e..d785405a 100644 --- a/node-binance-api.js +++ b/node-binance-api.js @@ -710,7 +710,7 @@ let api = function Binance( options = {} ) { ws.on( 'close', handleSocketClose.bind( ws, reconnect ) ); ws.on( 'message', data => { try { - callback( JSON.parse( data ) ); + callback( JSONbig.parse( data ) ); } catch ( error ) { Binance.options.log( 'Parse error: ' + error.message ); } @@ -761,7 +761,7 @@ let api = function Binance( options = {} ) { ws.on( 'close', handleSocketClose.bind( ws, reconnect ) ); ws.on( 'message', data => { try { - callback( JSON.parse( data ).data ); + callback( JSONbig.parse( data ).data ); } catch ( error ) { Binance.options.log( 'CombinedStream: Parse error: ' + error.message ); } @@ -961,7 +961,7 @@ let api = function Binance( options = {} ) { ws.on( 'close', handleFuturesSocketClose.bind( ws, params.reconnect ) ); ws.on( 'message', data => { try { - callback( JSON.parse( data ).data ); + callback( JSONbig.parse( data ).data ); } catch ( error ) { Binance.options.log( `futuresSubscribe: Parse error: ${ error.message }` ); } @@ -1610,7 +1610,7 @@ let api = function Binance( options = {} ) { ws.on( 'close', handleDeliverySocketClose.bind( ws, params.reconnect ) ); ws.on( 'message', data => { try { - callback( JSON.parse( data ) ); + callback( JSONbig.parse( data ) ); } catch ( error ) { Binance.options.log( 'Parse error: ' + error.message ); } @@ -1665,7 +1665,7 @@ let api = function Binance( options = {} ) { ws.on( 'close', handleDeliverySocketClose.bind( ws, params.reconnect ) ); ws.on( 'message', data => { try { - callback( JSON.parse( data ).data ); + callback( JSONbig.parse( data ).data ); } catch ( error ) { Binance.options.log( `deliverySubscribe: Parse error: ${ error.message }` ); }