Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement promise polyfill #40

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

clovis1122
Copy link

Adds the markdown to implement a Promise Polyfill. The PR is still not ready, but I wanted to open it to ask some questions.

@clovis1122 clovis1122 marked this pull request as draft October 6, 2020 01:41

### Question

Create a class `Promise` with two constructor parameters: `resolve` (fired when the promise is resolved) and `reject` (fired when the promise is rejected).
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nitish24p is this description ok? Do they need to implement the polyfill part (checking windows object to see if Promise is defined)? And do they need to make the promise fully compliant (implementing finally and the other promise static methods)?

@clovis1122 clovis1122 marked this pull request as ready for review October 7, 2020 01:07
### Solution

```javascript
function Promise(callback) {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me know if this solution is ok. I intentionally avoided modern JS syntax but can reconstruct the solution if needed. Some missing parts are that the then call does not follow returned promises, and the finally implementation.

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