-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Add Promise#finally proposal Stage 2 TC39 0716 #238
Conversation
var $export = require('./_export'); | ||
|
||
$export($export.P, 'Promise', { | ||
'finally': function _finally(onFinally){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Used _finally
. Error generated without the underscore.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use 'finally': function(onFinally)
. For ES6+ engines it will create the correct .name
, for old engines we can't do anything.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use 'finally': function(onFinally)
Done (not checked in yet...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Checked in.
var newPromise = Promise.prototype.then.call( | ||
this, // throw if IsPromise(this) is not true | ||
function(x) { | ||
return new C()(function(resolve) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're calling the result of new C()
as a function o_O
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's the behavior of the polyfill:
https://github.com/tc39/proposal-promise-finally/blob/84cec8005364a0cae413cad3be1e47b6a26be369/polyfill.js#L33
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It crashes at runtime 🙀
I've asked the author about it, but it's most likely accidental leftovers from refactoring.
I am using a previous version of the polyfill that had a much simpler speciesConstructor
implementation (https://github.com/tc39/proposal-promise-finally/blob/c626fb5857e0564eff6ab6a5b5e2b9383c156ba7/polyfill.js).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kovensky:
- Thanks for the older implementation reference. That's what I would expect. I like to move methodically through uncharted waters.
- I'll use the core-js internal implementation of
speciesConstructor
used ines6.promise.js
- Thanks for the quick responses!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It behaves correctly without the excess ()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Checked in.
Summary of changes: #238 (comment)
bd0de19
to
33d962c
Compare
Any test code you can point me to that work similarly to the pseudocode? I should have more time this weekend. |
Is this still being worked on? |
Promise#finally proposal Stage 2 from TC39 meeting on 2016-07.
Used implementation of
String#padStart
,String#trimLeft
, andPromise#then
as examples.Initial open items
finally
for the function name, perhaps because it is a reserved keyword. Temporarily used_finally
for implementation and test (commented below).core-js
Promise polyfill will set species, but, if I'm not mistaken, it's possible thatfinally
may berequire
d without the Promise polyfill. Sincecore-js
has its own method of setting species, what should be done?delay
finally
implementation is not in an internal file, but directly in the imported one. I am not supposing that it would be used by other functions in the library. Should I rather assume that it may be?