Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I'd use standard String.prototype.padStart. For anything more complicated, but not too complex (say "libraries" with 100-300 lines of code), it's very tedious and time consuming to find something on npm that satisfies the specific contraints of my app precisely. This certainly fits in that category.

For libraries above 1-2k lines of code that can be quite complicated (eg. things like database connectors), it starts being reasonable to mold expectations of my app around the library.

Also using coherent large utility libraries is something worthwhile (or was in the past), libs like underscore/lodash, etc.

But composing app from random underdocumented 2 function "libraries" from npm is just pain if you know what you're looking for. 1) you can't trust the code, so 2) you have to read it anyway and reading is often slower than writing



Searching for a package on npm is more time-consuming than writing 300 lines of code? Perhaps your app has some very specific constraints, but for a simple library like this, I have a hard time believing you could code something up on the fly faster than it would take to npm install the package in question.


I have absolutely written a diffing algorithm like this faster much than it would take to find an appropriate version on npm.

Every so often I try to reach for an npm library, only to find out that it's suboptimal, doesn't handle my edge cases, or just plain worse than the code I would have written.

The last time I tried to do this, I wanted a hash map with custom equality functions on the keys, since JS doesn't have one built-in by default. I searched for about 2 hours and didn't find a single one that actually worked (several claimed to be, but actually didn't work...)

So I wrote my own in about 100 lines. [0]

Data structures and algorithms tend to be really awful on npm.

[0] https://github.com/magcius/noclip.website/blob/master/src/Ha...


In the long term, having to manage all these dependencies, keeping track of incompatibility, testing updates, or worse, the lack of management, is time consuming.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: