Filter Frame Stream
Filter data frames from a stream of buffers by a head marker and optional tail—or trailing—marker, keeping these bytes intact in the returned chunks. This is useful when splitting up a stream of data with embedded frames used by some protocols (especially useful for variable length frame protocols), or even for extracting other data, such as JPEG images.
npm install --save filter-frame-stream
To filter the frame buffers you desire, provide your frame start/head and end/tail as arguments, along with an optional encoding. The arguments are as follows:
filterFrame(start, end, enc)
If not provided,
start will default to
0x00. Without specifying an
end value (or if
end is set to
false) the buffers will include
everything up until the next occurrence of the
end may be either a string or buffer. If not
enc will default to
utf8, although any node-compatible
The following is a silly example of how you would filter all websocket frames:
const filterFrame =processstdin
For more examples, see the tests.
ISC, see LICENSE for details.