JavaScript Flaws: 5 stupid NPM packages
As co-founder of Codesphere and Ex-Googler I have been passionate about coding since I was a child. I love NodeJS/JavaScript/Typescript with all their flaws (and there are many lol). One of these flaws for which the JavaScript Community takes a ton of heat is NPM.
For those who do not know NPM — let me explain: NPM is the dominant package manager for JavaScript and NodeJs and it allows importing other source code into your project.
As you probably know, NPM is a pretty easy meme target, unless you avoided the internet for the last couple of years. The promise is that you include ten things, ten things depend on five things, five things depend on ten things and the next thing is that you have half a gigabyte of node modules on your disk.
NPM is essentially unrestricted and even more than on wikipedia anyone can publish anything. This can even lead to a point where you publish something that is meant to be a joke and people actually start depending on it. One example where unnecessary dependencies have been dangerous is leftpad, a library that prepended a number of characters to a string. Its removal led to outages all over the internet.
Here are my TOP 5 Unnecessary NPM Libraries on which people actually depend:
1: is-ten-thousand
This library is used to find out if (yep, actually) a number is equal to ten thousand.
There are actually some people depending on it and if you need even more help with questions of this kind, there are also is-hundred and is-ten available at your command.
Funny enough, is-ten even states how it is used by 10x engineers ;)
2: owoifyx
This library is very straightforward to use and it does exactly what you would expect:
It ‘owoifies’ (Hello -> Hewwo) your text.const owoify = require(‘owoifyx’);
console.log(owoify(‘Hello friend!’)); // Hewwo fwiend (*^ω^)
26 people this week decided that they would need exactly this in their project.
3: true
This package is “A JavaScript port of the Unix utility ‘true’” and it returns ‘true’.
It even states how it should be used when you need a function that returns true.
The super clean three lines of code were developed by nine contributors in 30 commits, and
like every good package, it has 100% test coverage. You might think: Why not use the built in constant ‘true’? — Uhm.. I don’t know!
More than 300 people couldn’t live without this core utility this week.
There is also a companion package false which does exactly the same for false.
4: emoji-poop
As one would expect, this returns the poop emoji, but what is really great about this piece of code is that this also has a 100% test coverage and therefore will — guaranteed! — return the poop emoji.
11 people this week used it, maybe to prove a point?
5: is-odd
A trivial operation to do in JavaScript, though the most used library in this list. It returns true if a number is odd, and it has more than 500k downloads this week.
For all of you who might have wondered if you could also check if a number is even?
Surprise — this package exists (is-even) and was downloaded more than 100k times this week.
Fun fact: After some investigation by the Codesphere experts, we found that it imports the is-odd package, and negates it to your convenience.
Many thanks for reading this post, hope you liked it! What’s your favorite NPM package?