How does what you mean by .then here differ from .flatMap? If it is the same, why not rename your .then to .flatMap and rename your .when to .then ?
On Mon, Aug 19, 2013 at 8:14 PM, Kevin Smith <[email protected]> wrote: > 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 > > { Kevin } > > -- Cheers, --MarkM
_______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

