Kevin Smith (2013-08-20T03:14:54.000Z)
domenic at domenicdenicola.com (2013-08-29T19:08:30.042Z)
Implementation: function unwrap(value) { return Promise.resolve(value).then(v => isPromise(v) ? unwrap(v) : v); } Promise.when = value => unwrap(value); Test: var promise = new Promise(r => { r.fulfill(new Promise(r => { r.fulfill(1); })); }); promise.then(val => console.log(val.then ? "promise" : "value")); Promise.when(promise).then(val => console.log(val.then ? "promise" : "value")); >> promise >> value