From 34ecc7c156c18c962944cd44ab9b1181f465266b Mon Sep 17 00:00:00 2001 From: R4SAS Date: Sun, 30 Jun 2019 11:59:24 +0000 Subject: [PATCH] parse values as float before using toFixed (for node 8+) --- routes/block.js | 2 +- routes/index.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/routes/block.js b/routes/block.js index 79bc364..ae40108 100644 --- a/routes/block.js +++ b/routes/block.js @@ -28,7 +28,7 @@ router.get('/:hash', async function(req, res, next) { const block = blockInstance.toJSON(); block.confirmations = lastBlock.maxheight - block.height + 1; block.time = block.time.toUTCString(); - block.difficulty = block.difficulty.toFixed(8); + block.difficulty = parseFloat(block.difficulty).toFixed(8); block.hashrate = block.hashrate.toLocaleString() + " H/s"; res.render('block', { block, diff --git a/routes/index.js b/routes/index.js index d231683..36c3021 100644 --- a/routes/index.js +++ b/routes/index.js @@ -24,7 +24,7 @@ router.get('/', async function(req, res, next) { }); blocks.forEach(function(arrayItem) { arrayItem.ago = arrayItem.time.toUTCString().substring(5); - arrayItem.difficulty = arrayItem.difficulty.toFixed(8); + arrayItem.difficulty = parseFloat(arrayItem.difficulty).toFixed(8); arrayItem.hashrate = formatRate(arrayItem.hashrate, 4); }); res.render('index', {