From 6d310ef96885496f87ad5c23d2bd97d33a416fca Mon Sep 17 00:00:00 2001 From: Matthew Little Date: Sat, 22 Feb 2014 21:13:14 -0700 Subject: [PATCH] Cleaner message stream reading --- lib/peer.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/peer.js b/lib/peer.js index 45ab6ff..74f45dd 100644 --- a/lib/peer.js +++ b/lib/peer.js @@ -24,10 +24,7 @@ var readFlowingBytes = function(stream, amount, preRead, callback){ buff = Buffer.concat([buff, data], 2); if (buff.length >= amount){ var returnData = buff.slice(0, amount); - var lopped; - - if (buff.length > amount) - lopped = buff.slice(amount); + var lopped = buff.length > amount ? buff.slice(amount): null; callback(returnData, lopped); } else