The Promise.resolve/.cast tldr
# Mark S. Miller (11 years ago)
On Mon, Feb 24, 2014 at 10:13 AM, Jeff Morrison <lbljeffmo at gmail.com> wrote:
Promise.resolve('hai'); // Promise('hai')
If by the comment's notation you mean a promise whose fulfillment is "hai",
yes.
Note though that the call Promise("hai")
doesn't do this.
Promise.resolve(Promise.resolve('hai')); // Promise('hai') <-- is that right? I'm not sure where we're at here
yes.
Promise.resolve('hai').then(function(value) {
console.log(value); // prints 'hai'
});
yes.
Promise.resolve(Promise.resolve('hai')).then(function(value) { console.log(value); // prints 'hai' });
yes.
Promise.cast === undefined; // true
yes. A bit more informatively:
'cast' in Promise; // false
Promise.prototype.chain === undefined; // true
yes. And likewise
'chain' in Promise.prototype; // false
PLEASE do not turn this into another debate thread, I'm really just looking for a tldr thread tracking the latest standing on that topic. If the standing changes again, feel free to update this thread -- but otherwise please keep discussion in the other thread.
;)
Ok, so I've read most of the "Promise.cast/Promise.resolve" thread and it's gone back and forth and branched in topic several times...but now I'm a bit confused as to where we sit (and navigating that thread again isn't the most exciting idea). So can someone who's been following that thread more closely please confirm for (or correct) me that the following is where we sit at the moment:
Promise.resolve('hai'); // Promise('hai') Promise.resolve(Promise.resolve('hai')); // Promise('hai') <-- is that right? I'm not sure where we're at here Promise.resolve('hai').then(function(value) { console.log(value); // prints 'hai' }); Promise.resolve(Promise.resolve('hai')).then(function(value) { console.log(value); // prints 'hai' }); Promise.cast === undefined; // true Promise.prototype.chain === undefined; // true
PLEASE do not turn this into another debate thread, I'm really just looking for a tldr thread tracking the latest standing on that topic. If the standing changes again, feel free to update this thread -- but otherwise please keep discussion in the other thread.