TDI.online Tech. Music. Games.

LOLScript

I hate Javascript. I spent a fair few years working with it, and while it’s kinda fun doing filthy hacks to get things to work, fuck actually maintaining that shit.

Case in point. Watch the stack break…

I dunno what the worst part of this story is. Javascript engineers including a function as a dependency, or NPM allowing code to be ‘unpublished’. The first is just fucking stupid, and the second implies that you can’t rely on any module you import even fucking existing.

But just consider this: a function to pad the left hand side of a string was imported over 2 million times in a month. I’m fairly sure you could write that function in less time than it’d take to Google it.

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;
}

FFS