proposal-iterator-helpers icon indicating copy to clipboard operation
proposal-iterator-helpers copied to clipboard

avoid using PromiseResolve with a value known not to be a Promise

Open bakkot opened this issue 2 years ago • 1 comments

A slight tweak to https://github.com/tc39/proposal-iterator-helpers/pull/215.

The reason to use PromiseResolve is to get the fast-path when the value being passed is expected to be a Promise. On this particular line we've just created the iterator result object with which we are resolving, so we know the value is not a Promise. This is equivalent but (I think) clearer.

If this isn't accepted, the ? in the Return ? PromiseResolve should at least be changed to !, since the throwy case is guarded on IsPromise of the argument.

bakkot avatar Aug 10 '22 16:08 bakkot

I think I'd rather leave PromiseResolve and just use the !.

michaelficarra avatar Aug 12 '22 19:08 michaelficarra