node-stream-spliter

split a stream as discreate messages

Usage no npm install needed!

<script type="module">
  import nodeStreamSpliter from 'https://cdn.skypack.dev/node-stream-spliter';
</script>

README

StreamSpliter is for split message streams and emit discreate messages event. There are two types of StreamSpliters, as the follow:

Message has length send in its first bytes.

Message

对于按行分割的输入流,如果使用 emit 行到达事件的方式当然是非常的简单,但是如果想按照 obj.readLine(s) 的方式读就比较困难。 因为可能那时还没有行到达,最好的实现方式其实是阻塞方式,当没有行时,就等待,直到有了新行为止。

当然,行分割器可能会提示新的消息到达,然后