Javascript 如何编写嵌套承诺

Javascript 如何编写嵌套承诺,javascript,ecmascript-6,es6-promise,Javascript,Ecmascript 6,Es6 Promise,考虑这段代码,其中开始,继续和完成是承诺 export const do = () => { return new Promise((resolve, reject) => { start() .then(() => continue()) .then(() => finish()) .then(() => resolve()) .catch((r

考虑这段代码,其中
开始
继续
完成
是承诺

export const do = () => {
    return new Promise((resolve, reject) => {
        start()
            .then(() => continue())
            .then(() => finish())
            .then(() => resolve())
            .catch((reason) => reject(reason))
    });
};

这就是编写嵌套承诺的方法吗?

只需返回整个链,无需包装:

export const _do = () => start()
            .then(continue)
            .then(finish)
;

嗯,是的,那会有用的。但是只要
do=()=>start()。然后(继续)。然后(完成)
也可以,因为这已经是一个承诺,您不需要一个
新承诺。
。个人不会将其归类为重复,但它是相关的: