UNPKG

314 BJavaScriptView Raw
1/**
2 * 依次执行队列中的同步或异步函数
3 */
4const nextChain = (...args) => fns => {
5 let cur = 0;
6 const lastIndex = fns.length - 1;
7 const next = () => {
8 const _next = cur == lastIndex ? f => f : next;
9 fns[cur++].apply(null, [...args, _next]);
10 };
11 next();
12};
13
14export default nextChain;