Neoclassical Piano Montage

    filter-frame-stream

    1.0.3 • Public • Published

    Filter Frame Stream

    npm
    npm version
    travis
    stable

    Overview

    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.

    Installation

    npm install --save filter-frame-stream

    Usage

    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 start delimiter/marker.

    Both start and end may be either a string or buffer. If not provided, enc will default to utf8, although any node-compatible encoding works.

    The following is a silly example of how you would filter all websocket frames:

    const filterFrame = require('filter-frame-stream')
     
    process.stdin
      .pipe(filterFrame(Buffer.from('00', 'FF', 'hex')))
      .pipe(process.stdout)

    For more examples, see the tests.

    License

    ISC, see LICENSE for details.

    Install

    npm i filter-frame-stream

    DownloadsWeekly Downloads

    0

    Version

    1.0.3

    License

    ISC

    Last publish

    Collaborators

    • akiva