4 ms·
The utility file will never be updated and break your build without you doing it yourself.
by Ndymium 6y ago
The utility file will never be updated and break your build without you doing it yourself.
- hombre_fatal 6y agoAlso you can just read the code the same way you read any other code. And since it's in your codebase and git diffs, you will read it. Because the implementation detail of is-promise actually is important. It just checks if an object has a .then() method. So if you use it, it's just as important that you know the limitation. Not everything needs to be swept under the rug.
- darekkay 6y agoAlso: The utility file will never be updated and fix existing issues within the utility itself (unless you look up the package and diff it yourself). It's a trade-off.
- jhanschoo 6y agoAs the commenter who suggested keeping it in a utilities file, I'd say that the trade-off is heavily weighted to not importing it as a package. When you cribbed the code you should have completely understood what exactly the package was doing, and why, and known what issues it would have had. Since it's a one-liner, it is transparent. Since it is without dependencies, it is unlikely to fail on old code. So it's unlikely to have existing issues and unlikely to develop new issues. Of course, if you end up using new features of the language in your code, it may fail on that, but the risk old stuff failing should have already been factored in when you decided to upgrade. In fact, the one-liner solves this better since you decide the pace of adaptation of your one-liner to the new features, not the package maintainer.
- darekkay 6y agoThat's the trade-off I would most likely take in the "isPromise" case. But the opening question was a generic one ("What's the difference between a utility file and a package"), so the answer should reflect both sides.