From e2768d7e6960caa1e8886b5d84e4d6c60038140e Mon Sep 17 00:00:00 2001 From: Shinichi Katayama Date: Mon, 30 Nov 2015 10:12:02 +0900 Subject: [PATCH] Change the timing to emit 'msg' event to consume a buffer in advance --- lib/msgpack.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/msgpack.js b/lib/msgpack.js index 67c8d9e..f3d0271 100644 --- a/lib/msgpack.js +++ b/lib/msgpack.js @@ -74,7 +74,6 @@ var Stream = function(s) { break; } - self.emit('msg', msg); if (unpack.bytes_remaining > 0) { self.buf = self.buf.slice( self.buf.length - unpack.bytes_remaining, @@ -83,6 +82,7 @@ var Stream = function(s) { } else { self.buf = null; } + self.emit('msg', msg); } }); };