yjs / y-websocket

Websocket Connector for Yjs
https://docs.yjs.dev/ecosystem/connection-provider/y-websocket
MIT License
523 stars 261 forks source link

Update utils.js #114

Closed aryzing closed 2 years ago

aryzing commented 2 years ago

Added a comment to clarify why reply messages are not sent when their length is 1. Alternatively we could also create a function with a descriptive name of the check being performed,

function hasMessage(encoder) {
    return encoding.length(encoder) > 1;
}

The if statement would then look something like,

if (hasMessage(encoder)) {
    send(...);
}

Thoughts?

Huly®: YJS-751

dmonad commented 2 years ago

That works, thanks!