Skip to content

Commit

Permalink
change code style
Browse files Browse the repository at this point in the history
  • Loading branch information
icebob committed Oct 1, 2023
1 parent a0cec5f commit cad067d
Showing 1 changed file with 31 additions and 25 deletions.
56 changes: 31 additions & 25 deletions src/transit.js
Original file line number Diff line number Diff line change
Expand Up @@ -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", () => {
Expand Down Expand Up @@ -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", () => {
Expand Down

0 comments on commit cad067d

Please sign in to comment.