(targetId: TargetId, client: Client)
| 193 | }; |
| 194 | |
| 195 | export const addTargetClient = (targetId: TargetId, client: Client) => { |
| 196 | if (!isClient(client)) { |
| 197 | return; |
| 198 | } |
| 199 | |
| 200 | if (!Object.prototype.hasOwnProperty.call(targets, targetId)) { |
| 201 | throw new Error(`Sorry, but no ${targetId} target exists to add clients to`); |
| 202 | } |
| 203 | |
| 204 | if (Object.prototype.hasOwnProperty.call(targets[targetId], client.info.key)) { |
| 205 | throw new Error( |
| 206 | `the target ${targetId} already has a client with the key ${client.info.key}, please use a different key`, |
| 207 | ); |
| 208 | } |
| 209 | |
| 210 | targets[targetId].clientsById[client.info.key] = client; |
| 211 | }; |
no test coverage detected
searching dependent graphs…