Friday's Wednesday post: Top of the most “necessary” NPM packages
Hi Habr! Everyone knows what NPM is. Eeee, who called out the "garbage" ?! NPM is really a must-have tool for almost any JS developer. I bet that if you are one of them, somewhere in your project there is necessarily a package.json file (or maybe not one). At the time, NPM made a lot of noise: half of the Internet almost broke due to one package . And what from this? Welcome under cat.
Even at that time, there were a lot of
1. Perfect framework
Zero dependencies, open license, zero size, maximum performance, really clean code! Well, fiction and not framework, is not it? They say before the appearance of these your angulyars and reactors it was on it that everyone wrote. Your favorite framework is
Incredibly concise code
2. A tool to increase stability in the system
In any system there is always a critical place, to which it is not allowed to fall. This can be processing of banking transactions, warming up the cache, or searching for a million visitors to the site to give him a prize. In such cases, you always want to be sure that everything will go as it should. This package will allow you to measure your luck in order to be confident in your abilities. Today, good luck to you smiles? We start rebuilding the whole project right on production! Is luck below average? Don't even look at the console, man.
3. Sort with complexity in O (n)
Any programmer knows sorting is our everything. Without sorting, you cannot show a button, generate a report, or even simply add two numbers. Why else would they be so diligently taught at any university? Doot. In general, the sorting for O (n) is in any language , but what it is specifically for JS is, of course, good.
Although the license for this package and MIT-shnaya, but its author, for some reason, does not recommend using it in production. Why? Probably afraid that the code will become too fast. It's a pity. Only 17 lines of code , zero dependencies, O (n) is a dream, not sorting!
4. Modern approach to the use of a semicolon
Hardcode is always bad. But what if you still had to go to such a terrible thing? If you had to write something like “Everything is OK;” in the code - do not worry, you can make your code cleaner. No need to hardcode a semicolon - just use this package .
const greet = "Hello, habr;"// very badconst greet = "Hello, habr" + semicolon(); // much better!
In addition, the package can do a lot of useful things. Semicolon in korean?
To help you. Want to know if you slip a semicolon? semicolon.isSemicolon will help you out. In short, this is a Swiss knife in the world of semicolons.
5. Calm approach to boolean values.
I already see how you can not wait to go and implement previous packages in production, so this is the last, honestly.
Now imagine: you have this code:
But here you need to get an inversion of this value. How do you do this? Yes, most likely like this:
And if you need inversion inversion (well, you never know)?
Already like this:
A lot of exclamation marks, is not it? Too expressive, too emotional! But, fortunately, NPM has a solution to this problem.
import'toggle-boolean'const myBoolean = truelet anotherOne = !myBoolean; // wow wow wow! Take relax, man! anotherOne = myBoolean.toggle(); // much better!
That's all, good - little by little! Run to uncover your NPM, and make your life easier, and the code is cleaner and faster!
But now, seriously, how do you think, is this humor acceptable in professional tools? Jokes jokes - but these are really real packages, and you can really install and use them.
Only registered users can participate in the survey. Sign in , please.