5 ms·
Literally what it says: https://github.com/left-pad/left-pad/blob/master/index.js https://github.com/left-pad/left-pad/blob/master/index.js Now if you ask "but
by scambier 6y ago
Literally what it says: https://github.com/left-pad/left-pad/blob/master/index.js https://github.com/left-pad/left-pad/blob/master/index.js
Now if you ask "but why?", ultra-small packages like this are popular in JS because of the lack of a standard lib. Lots of devs prefer to install a dependency for each one-liner utility rather than write them themselves.
The only added value of those packages is that they're usually unit-tested against weird edge-cases that you might miss if you wrote them yourself.
Edit: related discussion at https://news.ycombinator.com/item?id=20223190 https://news.ycombinator.com/item?id=20223190
- TAForObvReasons 6y agothe small libraries are best compared to stackoverflow code snippets. Instead of reading and copying a solution that may be out of date, you can use a (theoretically) tested solution that receives bug fixes. In many ways it is superior to the copy and paste of lore
- chris_wot 6y agoThe smaller the library, the better.
- crehn 6y agoThe less there are dependencies, the better.
- vxNsr 6y agoYou're misunderstanding, what is the use-case of that specific package? like I've never found myself needing to pad text on the left, just trying to understand why this was such an important package.
- zomglings 6y agoProbably for command line tools that need to add some level of hierarchy into their output. You can add 1 to pad length and pass it to a subcomponent to display its output.
- scambier 6y agoI don't have any use for it either, but this package is not important by itself. It happens that this package is (was) at the very bottom of the dependency chain for some huge packages (like Babel, Webpack, popular frameworks, ...). When its creator removed it, they literally destroyed the foundation of those popular packages. That's what made it suddenly important.