MCPcopy
hub / github.com/socketio/socket.io / isPacketValid

Function isPacketValid

examples/basic-websocket-client/src/index.js:250–265  ·  view source on GitHub ↗
(packet)

Source from the content-addressed store, hash-verified

248}
249
250function isPacketValid(packet) {
251 switch (packet.type) {
252 case SIOPacketType.CONNECT:
253 return typeof packet.data === "object";
254 case SIOPacketType.DISCONNECT:
255 return packet.data === undefined;
256 case SIOPacketType.EVENT: {
257 const args = packet.data;
258 return (
259 Array.isArray(args) && args.length > 0 && typeof args[0] === "string"
260 );
261 }
262 default:
263 return false;
264 }
265}
266
267export function io(uri, opts) {
268 if (typeof uri !== "string") {

Callers 1

decodeFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected