4 ms·
This is why, this package is downloaded over a million times a week, all it does is trim a string. https://www.npmjs.com/package/trim https://www.npmjs.com/pack
by GrumpyNl 8y ago
This is why, this package is downloaded over a million times a week, all it does is trim a string. https://www.npmjs.com/package/trim https://www.npmjs.com/package/trim Can you imagine you need to depend on a external library for a trim function. Dont get me starting about the security issues.
- blattimwind 8y agoWhat feels bizarre to me is that you can't get the package from npmjs.com, there are no links to code etc. on there. Instead, use the API as a human (https://registry.npmjs.org/trim https://registry.npmjs.org/trim) to find the download link (https://registry.npmjs.org/trim/-/trim-0.0.1.tgz https://registry.npmjs.org/trim/-/trim-0.0.1.tgz), extract it locally, then find the source.
- slededit 8y agoIt would make sense if it handled gnarly Unicode issues. It appears this does not however.
- maxxxxx 8y agoI just started doing some JavaScript work and from what I have seen so far, a lot of packages are just amateur work thrown together quickly. In the C/C++ world I couldn't see stuff like this getting any adoption but in JavaScript this seems to happen.
- krapp 8y agoThe problem here isn't depending on an external library for a trim function -- all it does is wrap string.replace, so minimal if any non-native functionality is actually being provided. The problem is that something this basic is considered a complete library. If you know regex you could write this on your coffee break. If you don't, you could look it up and still write in on your coffee break. If you want trim and do anything else with a string, you need another dependency tree. This is not even really a problem with javascript lacking a standard library, so much as a problem with the accepted practices of the javascript community.
- AboutTheWhisles 8y agoExactly - if you could copy and paste a function, having it as a full library dependency is insanity.
- robocat 8y ago> you could write this in your coffee break When the trim library was needed, you likely also needed to support IE8. But IE8 has a bug where \s doesn't match a non-breaking whitespace \u00a0 - http://www.nivas.hr/blog/2012/01/19/non-breaking-white-space-in-internet-explorer-8-bug-and-how-to-fix-it/ http://www.nivas.hr/blog/2012/01/19/non-breaking-white-space... And you need to decide whether you polyfill or ponyfill the function. Yes you can theoretically do a trivial function in your break. With real browsers in practice you will often find your trivial function just isn't trivial.
- krapp 8y ago>With real browsers in practice you will often find your trivial function just isn't trivial. But the string trim package mentioned above is that trivial.