1.0.0 • Published 8 years ago

pull-block-filter v1.0.0

Weekly downloads
2
License
Fair
Repository
-
Last release
8 years ago

pull-block-filter

Filter parts of a stream of buffers in blocks.

Example

var blockFilter = require('pull-block-filter')
var pull = require('pull-stream')

pull(
  pull.once(new Buffer([1, 2, 3, 4, 5, 6, 7, 8])),
  blockFilter(pull.values([{skip: 1, length: 2}, {skip: 3, length: 1}])),
  pull.collect(function (err, bufs) {
    var buf = Buffer.concat(bufs)
    // buf: Buffer([2, 3, 7])
  })
)

API

blockFilter(readBlock) : through stream

  • readBlock: through stream of blocks for filtering
    • block.skip (int, default: 0): number of bytes/elements to skip before reading
    • block.length (int, default: 0): number of bytes/elements to read

Create a through stream that filters data based on readBlocks. readBlocks is a source stream of objects representing how to read the source stream that is pulled through blockFilter(). Each skip means to skip some number of bytes/elements from the source stream, and length means to then pass through some bytes/elements.