4 ms·
There is a NPM package lodash.debounce if you only want this feature from lodash. Lodash is available splitted in many small packages.
by speedgoose 6y ago
There is a NPM package lodash.debounce if you only want this feature from lodash. Lodash is available splitted in many small packages.
- _bxg1 6y agoThe point remains, though, that I avoided an unnecessary dependency. I copied that function once and never needed to mess with it again, because it was 15 lines and I could verify personally that it did what it needed to do. For contrast, we wanted to be able to incorporate new versions of React, because it isn't a simple enough thing that it can be written once and be done. It evolved, and offered real improvements in terms of performance and useful features. As in all things, there are costs and benefits to making something an external dependency or not. The key is to realize that there are indeed tradeoffs, and that outsourcing every single thing you can isn't necessarily ideal.
- entropicdrifter 6y agoRight, but his point about that was essentially: "Why depend on that as a dependency rather than just have a copy directly in my project that I know will never behave any differently?"
- speedgoose 6y agoBecause it's one line to a dependency with a name, a documentation, a bug tracker, many users, and that could be improved in the future. If you are scared about packages behaving differently, you should know that npm has lock files that describes your full dependency tree with versions and checksums.
- majormajor 6y ago"Could be improved in the future" is a risk when it comes to a simple utility function that does a simple thing that you don't want to change. In the same way that someone constantly tweaking your utility functions in your own project would be a risk - and you'd understandably want to code review all that - the more you choose to (or have to) outsource "trivial" stuff, the more brittle your project is.
- ioseph 6y agoHence the lockfile, on the flipside if you've copy and pasted source across which contains a security update you'll most likely not realise
- snovv_crash 6y agoIn any other package ecosystem you'd be laughed out of the room for suggesting to add a dependency for a 15 line function, instead of just copying it into your codebase. And the 15 line function here is a fairly major function. People add dependencies for 2 or 1 line functions!