kevinbeaty / any-promise

NOTE: You probably want native promises now
MIT License
179 stars 17 forks source link

check for duplicate implementations #8

Closed jonathanong closed 8 years ago

jonathanong commented 8 years ago

i.e. attach stuff to global and return the same instance of any-promise if for some reason there are multiple copies of it.

kevinbeaty commented 8 years ago

I considered this in #1, but ended up just adding a note in the README about removing installations not at the top level if registering a preferred implementation (using npm dedupe or manually if npm3 doesn't take care of it for you).

I'm thinking it would only be required if registering a preferred implementation since it defaults to global.Promise, but I may be wrong. Is there a reason to do it all the time?

I was hesitant to add a global variable, but it's probably not a big deal if I use something unlikely to conflict, e.g. global['@@ANY_PROMISE_REGISTRATION'].

analog-nico commented 8 years ago

+1 for global['@@ANY_PROMISE_REGISTRATION']

I am about to add any-promise to request-promise and I would now need to add the npm dedupe instructions to request-promise's README as well. IMHO this makes it too complicated for the library users. To be fair running npm dedupe once in your dev environment is one more thing to take care of but doable. But how about the CI systems and the production deployment? Still doable but already pretty involved I would say...

kevinbeaty commented 8 years ago

Published 1.1.0 with global registration to prevent duplicate implementations.

Thanks!

analog-nico commented 8 years ago

Awesome, thanks you @kevinbeaty !