Skip to content

Conversation

jesuisYves
Copy link

The current implementation of resolve in Thenable has a major flaw and does not support chaining syntax. It throws an error once called with additional .then:

TypeError: next.then is not a function

I was going to add some comments to #4, where this issue had been addressed, but the author seems to have been inactive for the last few years, so I decided to create a new pull request.

The reason for the problem is that the local next variable is actually the result of the current resolve function, and not the next Thenable instance.

Such naming also inspired another problem. If the result of the current resolve function has a falsy value it will not pass if (next) and the whole following chain will be omitted.

I fixed the resolve logic to support additional chains and extended the usage example to prove it does work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant