anephenix / sarus

A WebSocket JavaScript library
https://sarus.anephenix.com
MIT License
218 stars 6 forks source link

Fix ambiguity in retryConnectionDelay #402

Closed justuswilhelm closed 9 months ago

justuswilhelm commented 10 months ago

When false, true or undefined are passed as retryConnectionDelay, they are all interpreted as 1000 ms. We change the constructor to interpret any value other than a number as 1000 ms. This allows us to simplify the value that is stored internally to just a number, and the complexity of the reconnect() method also goes down.

Implementers can use false as before, but false being interpreted as 1000ms is made more explicit. We can therefore easily see that the untested immediate connection line will never be hit, since given the default value in the constructor, a retryConnectionDelay was never going to be false.

justuswilhelm commented 9 months ago

Much appreciated! Thank you

paulbjensen commented 9 months ago

You're welcome, sorry I haven't been as available as I ought to be with GitHub items.