({ cmds, batch = false }, context)
| 96 | } |
| 97 | |
| 98 | function handleSequenceList({ cmds, batch = false }, context) { |
| 99 | const firstCmd = cmds.length ? cmds[0] : null; |
| 100 | if (!firstCmd) { |
| 101 | return null; |
| 102 | } |
| 103 | |
| 104 | const result = new Promise((resolve) => { |
| 105 | let firstPromise = executeCmdInternal(firstCmd, context); |
| 106 | firstPromise = firstPromise || Promise.resolve([]); |
| 107 | firstPromise.then((result) => { |
| 108 | let executePromise; |
| 109 | if (!batch) { |
| 110 | executePromise = Promise.all( |
| 111 | result.map((a) => context.wrappedDispatch(a)) |
| 112 | ); |
| 113 | } else { |
| 114 | executePromise = Promise.resolve(); |
| 115 | } |
| 116 | executePromise.then(() => { |
| 117 | const remainingSequence = list(cmds.slice(1), { |
| 118 | batch, |
| 119 | sequence: true, |
| 120 | }); |
| 121 | const remainingPromise = executeCmdInternal(remainingSequence, context); |
| 122 | if (remainingPromise) { |
| 123 | remainingPromise.then((innerResult) => { |
| 124 | resolve(result.concat(innerResult)); |
| 125 | }); |
| 126 | } else { |
| 127 | resolve(result); |
| 128 | } |
| 129 | }); |
| 130 | }); |
| 131 | }).then(flatten); |
| 132 | |
| 133 | return batch ? result : result.then(() => []); |
| 134 | } |
| 135 | |
| 136 | function handleDelayCmd(cmd, context) { |
| 137 | const executeNestedCmd = () => { |
no test coverage detected