Skip to content

Commit

Permalink
Style changes
Browse files Browse the repository at this point in the history
  • Loading branch information
slaskis committed Mar 13, 2013
1 parent 4cf3de6 commit 7d63868
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions index.js
Expand Up @@ -44,14 +44,17 @@ NetChannel.prototype = {

send: function(msg){
// accept any TypedArray
if( msg && (msg.buffer instanceof ArrayBuffer) )
if( msg && (msg.buffer instanceof ArrayBuffer) ){
msg = msg.buffer;
}

if( !(msg instanceof ArrayBuffer) )
if( !(msg instanceof ArrayBuffer) ){
throw new Error('invalid message type, only binary is supported');
}

if( msg.byteLength > 255 )
if( msg.byteLength > 255 ){
throw new Error('invalid message length, only up to 256 bytes are supported')
}

// grow by 3 bytes (seq & len)
var seq = this.seq++;
Expand All @@ -69,8 +72,9 @@ NetChannel.prototype = {
},

flush: function(){
if( this.bufferLength && this.channel )
if( this.bufferLength && this.channel ){
this.channel.send(this.encoded || this.encode());
}
},

// encodes into a message like this:
Expand Down

0 comments on commit 7d63868

Please sign in to comment.