Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: sockLen being miscalculated when removing sockets
Order of operations issue with + and ternary statements: console.log(0 + '' ? 'a' : 'b') // a The code: freeLen + this.sockets[name] ? this.sockets[name].length : 0; Is equivalent to: (freeLen + this.sockets[name]) ? this.sockets[name].length : 0; Because `this.sockets[name]` is an array, `(freeLen + this.sockets[name])` evaluates to a string, which is true, so the left side of the ternary expression was always being chosen.
- Loading branch information