Leftpad: 11 lines of code that broke the internet in 2016


Fri Dec 27 2019 19:07:08 GMT+0000 (Coordinated Universal Time)

Saved by @bluespin223 #javascript #interesting #historicalcode #leftpad

module.exports = leftpad;
function leftpad (str, len, ch){
   str = String(str);
   var i = -1;
   if (!ch && ch !== 0) ch = ' ';
   len = len - str.length;
   while (++i < len){
      str = ch + str;
   return str;

This story will always fascinate me. How one programmer's fight for open source against a corporate takeover led to him deleting a package nobody knew about. It crashed any site that ran javascript. A package that had just 11 lines of code.