Skip to content

Commit 6af4b7a

Browse files
author
Kirill
committed
replace Promise.all with simple for-loop
remove extra emit end
1 parent f2c4656 commit 6af4b7a

14 files changed

+560
-166
lines changed

lib/actions/splitOnJsonata.js

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,14 @@ async function processAction(msg, cfg) {
1818
return;
1919
}
2020

21-
const results = [];
22-
split.forEach((elem) => results.push(elem));
23-
this.logger.info('Splitting the incoming message into %s messages', results.length);
21+
this.logger.info('Splitting the incoming message into %s messages', split.length);
2422

25-
await Promise.all(results.map(async (result) => {
26-
if (result) {
27-
await this.emit('data', messages.newMessageWithBody(result));
23+
for (let i = 0; i < split.length; i += 1) {
24+
if (split[i]) {
25+
// eslint-disable-next-line no-await-in-loop
26+
await this.emit('data', messages.newMessageWithBody(split[i]));
2827
}
29-
}));
30-
31-
await this.emit('end');
28+
}
3229
}
3330

3431
exports.process = processAction;

0 commit comments

Comments
 (0)