Download server/helpers.js from sharktide/chat: direct link, hf CLI and curl.
- Browser
- Download file 560 Bytes
-
https://huggingface.co/spaces/sharktide/chat/resolve/126e920d80ae2b40ca9c88fd394ed76922c57742/server/helpers.js
- Command line
-
hf download hf://spaces/sharktide/chat@126e920d80ae2b40ca9c88fd394ed76922c57742/server/helpers.js
-
curl -L -o helpers.js https://huggingface.co/spaces/sharktide/chat/resolve/126e920d80ae2b40ca9c88fd394ed76922c57742/server/helpers.js
560 Bytes
| // helpers.js — safeSend and broadcastToUser without importing from index | |
| // (avoids circular dependency index→wsHandler→index) | |
| export function safeSend(ws, data) { | |
| if (ws.readyState === 1) ws.send(JSON.stringify(data)); | |
| } | |
| // broadcastToUser needs access to wsClients which lives in index. | |
| // We pass it as a parameter instead. | |
| export function broadcastToUser(wsClients, userId, data, excludeWs = null) { | |
| for (const [ws, c] of wsClients) | |
| if (c.userId === userId && ws !== excludeWs && ws.readyState === 1) | |
| ws.send(JSON.stringify(data)); | |
| } | |