const leftpad = require('leftpad');
const toFixedLong = (input, decimalPoints = 1) => {
const floor = Math.floor(input)
let x = floor
let output = ''
while (x >= 1000) {
output = ',' + leftpad(x % 1000, 3, '0') + output;
x = Math.floor(x / 1000);
}
return '' + x + output + (input - floor).toFixed(decimalPoints).slice(1);
}
const input = 1234000000000000.245 // 1,234,000,000,000,000.245
const inputB = 1.3986383939661338e+308
console.log(toFixedLong(input))
console.log(toFixedLong(inputB))