Skip to content

Implement promise polyfill#40

Open
clovis1122 wants to merge 2 commits intonitish24p:masterfrom
clovis1122:feature/promise-polyfill
Open

Implement promise polyfill#40
clovis1122 wants to merge 2 commits intonitish24p:masterfrom
clovis1122:feature/promise-polyfill

Conversation

@clovis1122
Copy link
Copy Markdown

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
Copy Markdown
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
Copy Markdown
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