'use strict';

var filterParseSync = require('../../../../../../_virtual/filter-parse-sync.js');
var syncReader = require('./sync-reader.js');
var filterParse = require('./filter-parse.js');

let SyncReader = syncReader.syncReaderExports;
let Filter = filterParse.filterParseExports;

filterParseSync.__exports.process = function (inBuffer, bitmapInfo) {
  let outBuffers = [];
  let reader = new SyncReader(inBuffer);
  let filter = new Filter(bitmapInfo, {
    read: reader.read.bind(reader),
    write: function (bufferPart) {
      outBuffers.push(bufferPart);
    },
    complete: function () {},
  });

  filter.start();
  reader.process();

  return Buffer.concat(outBuffers);
};

module.exports = filterParseSync.__exports;
