jameslnewell / xhr-mock

Utility for mocking XMLHttpRequest.
196 stars 48 forks source link

Why use lie for Promises #19

Closed niekbosch closed 7 years ago

niekbosch commented 7 years ago

Using 'lie' as a Promise implementation gives me problems when using xhr-mock in an Angular 2 project. It does not work well with zone.js. Just removing the var Promise = require('lie'); lines, make it work nicely.

In node.js, there is a (native) implementation for promises. And most modern browsers seem to have one as well. Is there any particular reason why lie is used?

If not, would it be possible to leave it up to the user (of your library) to load a polyfill? Or, probably better (because backwards compatible), check if one is loaded before loading lie? Something like:

if (undefined === Promise) {
  var Promise = require('lie');
}
jameslnewell commented 7 years ago

Hi @niekbosch. lie isn't used in the currently published version of xhr-mock. It has been added as part of https://github.com/jameslnewell/xhr-mock/pull/18 which is still open. Can you please move your comment to the pull request. I tend to agree, I prefer to include polyfills at the project level rather than in the libraries.

niekbosch commented 7 years ago

You are right, sorry. I didn't realize I ended up using @AlehVasilyeu's fork.

Copied the comment to the pull request. Thanks for your response anyway!