'use strict';

var filterParseAsync = require('../../../../../../_virtual/filter-parse-async.js');
var require$$0 = require('util');
var chunkstream = require('./chunkstream.js');
var filterParse = require('./filter-parse.js');

let util = require$$0;
let ChunkStream = chunkstream.chunkstreamExports;
let Filter = filterParse.filterParseExports;

let FilterAsync = (filterParseAsync.__module.exports = function (bitmapInfo) {
  ChunkStream.call(this);

  let buffers = [];
  let that = this;
  this._filter = new Filter(bitmapInfo, {
    read: this.read.bind(this),
    write: function (buffer) {
      buffers.push(buffer);
    },
    complete: function () {
      that.emit("complete", Buffer.concat(buffers));
    },
  });

  this._filter.start();
});
util.inherits(FilterAsync, ChunkStream);

var filterParseAsyncExports = filterParseAsync.__module.exports;

exports.filterParseAsyncExports = filterParseAsyncExports;
