Skip to content

Commit

Permalink
minor refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
benStre committed Feb 10, 2024
1 parent e86d064 commit 2a5510c
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions network/communication-hub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -545,21 +545,21 @@ export class CommunicationHubHandler {
const receivers = data.receivers instanceof Endpoint ? [data.receivers] : [...data.receivers];
const outGroups = receivers.length == 1 ?

// single endpoint shortcut
new Map([[this.getPreferredSocketForEndpoint(receivers[0], data.socket), new Disjunction(...receivers)]]) :

// group for multiple endpoints
new Map(
// group receivers by socket
[...Map.groupBy(
// map receivers to sockets
receivers.map(r => ({endpoint: r, socket: this.getPreferredSocketForEndpoint(r, data.socket)}),
), ({socket}) => socket
).entries()
]
// map endpoint object arrays to Set<Endpoint>
.map(([k, v]) => [k, new Disjunction(...v.map(({endpoint}) => endpoint))] as const)
);
// single endpoint shortcut
new Map([[this.getPreferredSocketForEndpoint(receivers[0], data.socket), new Disjunction(receivers[0])]]) :
// group for multiple endpoints
new Map(
// group receivers by socket
[...Map.groupBy(
// map receivers to sockets
receivers.map(r => ({endpoint: r, socket: this.getPreferredSocketForEndpoint(r, data.socket)}),
), ({socket}) => socket
).entries()
]
// map endpoint object arrays to Set<Endpoint>
.map(([k, v]) => [k, new Disjunction(...v.map(({endpoint}) => endpoint))] as const)
);


const promises = []
Expand Down

0 comments on commit 2a5510c

Please sign in to comment.