Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: sockLen was being miscalculated when removing sockets #60

Merged
merged 2 commits into from Oct 18, 2018

Commits on Apr 10, 2018

  1. 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;
    
    When `this.sockets[name]` exists, it is an array, `(freeLen + this.sockets[name])` evaluates to a string, which evaluates to a string (true). When it does not, `(freeLen + this.sockets[name])` evaluates to `NaN` (false).
    Either way, `freeLen` is ignored.
    cixel committed Apr 10, 2018
    Copy the full SHA
    6ee9e21 View commit details
    Browse the repository at this point in the history

Commits on Oct 18, 2018

  1. Copy the full SHA
    723bb23 View commit details
    Browse the repository at this point in the history