<commit_before>var cadence = require('cadence')

var coalesce = require('extant')

var Pipeline = require('prolific.pipeline')
var Acceptor = require('prolific.acceptor')

function Processor (pipeline, configuration, nextProcessor) {
    this._acceptor = new Acceptor(coalesce(configuration.accept, true), coalesce(configuration.chain, []))
    this._pipeline = pipeline
    this._nextProcessor = nextProcessor
    this._consume = !! configuration.consume
}

Processor.prototype.process = function (entry) {
    var forward = true
    console.log('got', entry)
    if (this._acceptor.acceptByContext(entry)) {
        console.log('accepted')
        this._pipeline.process(JSON.parse(JSON.stringify(entry)))
        forward = ! this._consume
    }
    console.log('forward', forward)
    if (forward) {
        this._nextProcessor.process(entry)
    }
    console.log('processed')
}

module.exports = cadence(function (async, destructible, configuration, nextProcessor) {
    console.log('rebuilding', configuration)
    async(function () {
        destructible.monitor('pipeline', Pipeline, configuration.pipeline, async())
    }, function (pipeline) {
        return new Processor(pipeline, configuration, nextProcessor)
    })<commit_msg>Remove debugging messages.<commit_after>var cadence = require('cadence')

var coalesce = require('extant')

var Pipeline = require('prolific.pipeline')
var Acceptor = require('prolific.acceptor')

function Processor (pipeline, configuration, nextProcessor) {
    this._acceptor = new Acceptor(coalesce(configuration.accept, true), coalesce(configuration.chain, []))
    this._pipeline = pipeline
    this._nextProcessor = nextProcessor
    this._consume = !! configuration.consume
}

Processor.prototype.process = function (entry) {
    var forward = true
    if (this._acceptor.acceptByContext(entry)) {
        this._pipeline.process(JSON.parse(JSON.stringify(entry)))
        forward = ! this._consume
    }
    if (forward) {
        this._nextProcessor.process(entry)
    }
}

module.exports = cadence(function (async, destructible, configuration, nextProcessor) {
    async(function () {
        destructible.monitor('pipeline', Pipeline, configuration.pipeline, async())
    }, function (pipeline) {
        return new Processor(pipeline, configuration, nextProcessor)
    })
{'fraction_non_alphanumeric': 0.12182522600086096, 'fraction_numerical': 0.0, 'mean_word_length': 4.1759465478841875, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1336822', 'n_tokens_mistral': 639, 'n_tokens_neox': 646, 'n_words': 130}