Indeed, the Twitter API will respond to duplicate tweets if we do not reduce the max_id parameter.
Here is a good Twitter API article on max_id: https://dev.twitter.com/docs/working-with-timelines About the general concept of working with large (over 53-bit) numbers in JavaScritp: http://www.2ality.com /2012/07/large-integers.html
Back to the question: using the library seems redundant if you are not using it for something else. @bob-lauer has a nice lightweight solution, but I wrote my own function without recursion :
function decStrNum (n) { n = n.toString(); var result=n; var i=n.length-1; while (i>-1) { if (n[i]==="0") { result=result.substring(0,i)+"9"+result.substring(i+1); i --; } else { result=result.substring(0,i)+(parseInt(n[i],10)-1).toString()+result.substring(i+1); return result; } } return result; }
To test it, do the following numbers / lines:
console.log("290904187124985850"); console.log(decStrNum("290904187124985850")); console.log("290904187124985851"); console.log(decStrNum("290904187124985851")); console.log("290904187124985800"); console.log(decStrNum("290904187124985800")); console.log("000000000000000001"); console.log(decStrNum("0000000000000000001"));
source share