From cad067d5939a68220bb49218b049a1570f146083 Mon Sep 17 00:00:00 2001 From: Icebob Date: Sun, 1 Oct 2023 11:23:04 +0200 Subject: [PATCH] change code style --- src/transit.js | 56 ++++++++++++++++++++++++++++---------------------- 1 file changed, 31 insertions(+), 25 deletions(-) diff --git a/src/transit.js b/src/transit.js index a0723db33..2f8e4f593 100644 --- a/src/transit.js +++ b/src/transit.js @@ -895,23 +895,23 @@ class Transit { } else { chunks.push(chunk); } - const publishMap = chunks.map(ch => { - const copy = Object.assign({}, payload); - copy.seq = ++payload.seq; - copy.stream = true; - copy.params = ch; - this.logger.debug( - `=> Send stream chunk ${requestID}to ${nodeName} node. Seq: ${copy.seq}` - ); - - return this.publish(new Packet(P.PACKET_REQUEST, ctx.nodeID, copy)); - }); - - return this.Promise.all(publishMap).then( - () => stream.resume(), - publishCatch - ); + return this.Promise.all( + chunks.map(ch => { + const copy = Object.assign({}, payload); + copy.seq = ++payload.seq; + copy.stream = true; + copy.params = ch; + + this.logger.debug( + `=> Send stream chunk ${requestID}to ${nodeName} node. Seq: ${copy.seq}` + ); + + return this.publish(new Packet(P.PACKET_REQUEST, ctx.nodeID, copy)); + }) + ) + .then(() => stream.resume()) + .catch(publishCatch); }); stream.on("end", () => { @@ -1127,17 +1127,23 @@ class Transit { } else { chunks.push(chunk); } - const publishMap = chunks.map(ch => { - const copy = Object.assign({}, payload); - copy.seq = ++payload.seq; - copy.stream = true; - copy.data = ch; - this.logger.debug(`=> Send stream chunk to ${nodeID} node. Seq: ${copy.seq}`); + return this.Promise.all( + chunks.map(ch => { + const copy = Object.assign({}, payload); + copy.seq = ++payload.seq; + copy.stream = true; + copy.data = ch; - return this.publish(new Packet(P.PACKET_RESPONSE, nodeID, copy)); - }); - return this.Promise.all(publishMap).then(() => stream.resume(), publishCatch); + this.logger.debug( + `=> Send stream chunk to ${nodeID} node. Seq: ${copy.seq}` + ); + + return this.publish(new Packet(P.PACKET_RESPONSE, nodeID, copy)); + }) + ) + .then(() => stream.resume()) + .catch(publishCatch); }); stream.on("end", () => {