function doAsync(result) {
return Promise.resolve(result)
.then(({ value = 'default' } = {}) => {
return value
})
}
Promise.resolve()
.then(() => {
return doAsync({ value: 'foo' })
.then((value) => {
console.log(value)
})
})
.then(() => {
return doAsync(undefined)
.then((value) => {
console.log(value)
})
})
.then(() => {
return doAsync(null)
.then((value) => {
console.log(value)
})
})