Earlier quoted context omitted.
I don't know how "clickbait" that title can be when it is, in fact, longer than the line of code in question: declare function isPromise (obj: Promise | S): obj is Promise ; This is, indeed, the only line of exported code in the entire package. I genuinely don't understand the NPM world.
Me neither. I can't wait for Deno 1.0 next month. https://deno.land/
A one-line package broke `npm create-react-app`
41–50 of 478 posts
Re: A one-line package broke `npm create-react-app`
#42Maybe not to this extend, but if X (where X is whatever you are thinking about) had similar amount of people using it (especially junior people) this would happen there as well.
Re: A one-line package broke `npm create-react-app`
#43This was an honest oversight, and even somewhat inevitable with so many expected supported ways to import/export between cjs mjs amd umd etc. It will happen again.
And when it happens the next time, if it ruins your life again, take issue with yourself for not pinning your dependency versions, rather that package maintainers trying to make it all happen.
Re: A one-line package broke `npm create-react-app`
#44Re: A one-line package broke `npm create-react-app`
#45And the source code of the library is: function isPromise(obj) { return !!obj && (typeof obj === 'object' || typeof obj === 'function') && typeof obj.then === 'function'; }
A function like this should be a package. Or, really, part of standard js, maybe.
A) The problem it solves is real. It's dumb, but JS has tons of dumb stuff, so that changes nothing. Sometimes you want to know "is this thing a promise", and that's not trivial (for reasons).
B) The problem it solves is not straightforward. If you Google around you'll get people saying "Anything with a .then is a promise' or other different ways of testing it. The code being convoluted shows that.
Should this problem be solved elsewhere? Sure, again, JavaScript is bad and no one's on the other side of that argument, but it's what we have. Is "just copy paste a wrong answer from SO and end up with 50 different functions in your codebase to check something" like other languages that make package management hard so much better ? I don't think so.
Re: A one-line package broke `npm create-react-app`
#46Earlier quoted context omitted.
My prior decision to never work with JavaScript again has just grown firmer.
I second this, JavaScript Devs are near the bottom of the food chain, just above VB Devs. Myself as a Java developer is middle of the pyramid. The apex predators are embedded developers, followed by c Devs then game Devs.
I loathe JS, but one of the best devs I know likes it. People's mileage varies.
For me personally, there's much more money in easy React products than making games. I'm not a great dev, but I'd be doing this same work even if I were.
Re: A one-line package broke `npm create-react-app`
#47Earlier quoted context omitted.
I don't know how "clickbait" that title can be when it is, in fact, longer than the line of code in question: declare function isPromise (obj: Promise | S): obj is Promise ; This is, indeed, the only line of exported code in the entire package. I genuinely don't understand the NPM world.
NPM is the answer to the question: what would happen if everyone refused to use any idioms ever, and instead replace them all with packages? God help you, if you import a JavaScript (or Rust) package today. Lest you fall in a gaping chasm of endless cascading dependencies.
I would never in my right mind publish a one-line package, Python, Javascript, whatever.
And I would never add a one line package as dependency
Re: A one-line package broke `npm create-react-app`
#48You can thank https://twitter.com/ForbesLindesay for breaking Node today.
Re: A one-line package broke `npm create-react-app`
#49Is someone going to fix that?
Re: A one-line package broke `npm create-react-app`
#50And the source code of the library is: function isPromise(obj) { return !!obj && (typeof obj === 'object' || typeof obj === 'function') && typeof obj.then === 'function'; }
class World { then () { return 0; } } isPromise(new World) // true
If there really isn't a safe and better way to tell if an object is an instance of Promise…then color me impressed.