diff --git a/lib/pkt-line.js b/lib/pkt-line.js index 4134462..18687ec 100644 --- a/lib/pkt-line.js +++ b/lib/pkt-line.js @@ -16,7 +16,7 @@ function deframer(emit) { var more = true; return function (item) { - + var doUndefined = false; // Forward the EOS marker if (item === undefined) return emit(); @@ -65,6 +65,7 @@ function deframer(emit) { state = 0; length = 0; if (data[0] === 1) { + var doUndefined = true; more = emit(bodec.slice(data, 1)); } else if (data[0] === 2) { @@ -90,7 +91,7 @@ function deframer(emit) { throw new Error("pkt-line decoder in invalid state"); } } - + if (doUndefined) emit(); return more; };