From 0a3a1b5ea6634be11e969eedcfb188fc8d010131 Mon Sep 17 00:00:00 2001 From: sairajzero Date: Mon, 17 Apr 2023 20:07:12 +0530 Subject: [PATCH] changing typeof to equivalent lodash --- lib/services/address/index.js | 4 ++-- lib/services/block/index.js | 4 ++-- lib/services/db/index.js | 2 +- lib/services/transaction/index.js | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/services/address/index.js b/lib/services/address/index.js index a93b9418..57cc0deb 100644 --- a/lib/services/address/index.js +++ b/lib/services/address/index.js @@ -180,7 +180,7 @@ AddressService.prototype.getAddressHistory = function(addresses, options, stream //options.from = options.from || 0; //Deprecated, use `after` option //options.to = options.to || 0xffffffff; //Deprecated, use `after` option - if(typeof callback !== 'function'){ //if only 3 args, then streamer is callback + if(!_.isFunction(callback)){ //if only 3 args, then streamer is callback callback = streamer; streamer = () => null; //NULL fn } @@ -319,7 +319,7 @@ AddressService.prototype.getAddressSummary = function(address, options, streamer options.queryMempool = true; } - if(typeof callback !== 'function'){ //if only 3 args, then streamer is callback + if(!_.isFunction(callback)){ //if only 3 args, then streamer is callback callback = streamer; streamer = () => null; //NULL fn } diff --git a/lib/services/block/index.js b/lib/services/block/index.js index cfee8a12..7884260c 100644 --- a/lib/services/block/index.js +++ b/lib/services/block/index.js @@ -724,13 +724,13 @@ BlockService.prototype._findLatestValidBlockHeader = function(callback) { // if some joker mines a block using an orphan block as its prev block, then the effect of this will be // us detecting a reorg, but not actually reorging anything // FLOSight Error Correction from RanchiMall 17th May 2021. removed the unhandled assert and replaced by looging of error - if (typeof header !== 'undefined') { + if (!_.isUndefined(header)) { if (header == false) { log.error('Block Service: we could not locate any of our recent block hashes in the header service ' + 'index. Perhaps our header service sync\'ed to the wrong chain?'); } } // assert(header, 'Block Service: we could not locate any of our recent block hashes in the header service ' + 'index. Perhaps our header service sync\'ed to the wrong chain?'); - if (typeof header.height !== 'undefined') { + if (!_.isUndefined(header.height)) { if (header.height > self._tip.height) { log.error('Block Service: we found a common ancestor header whose ' + 'height was greater than our current tip. This should be impossible.'); } diff --git a/lib/services/db/index.js b/lib/services/db/index.js index 1bcc57ef..b79db2db 100644 --- a/lib/services/db/index.js +++ b/lib/services/db/index.js @@ -95,7 +95,7 @@ DB.prototype.get = function(key, options, callback) { var cb = callback; var opts = options; - if (typeof callback !== 'function') { + if (!_.isFunction(callback)) { cb = options; opts = {}; } diff --git a/lib/services/transaction/index.js b/lib/services/transaction/index.js index 545046f8..2be34b58 100644 --- a/lib/services/transaction/index.js +++ b/lib/services/transaction/index.js @@ -114,7 +114,7 @@ TransactionService.prototype.getTransaction = function(txid, options, callback) var self = this; - if (typeof callback !== 'function') { + if (!_.isFunction(callback)) { callback = options; }