<commit_before>const ascension = require('ascension')
const sort = ascension([ Number ], entry => entry.when)

const Isochronous = require('isochronous')

class Printer {
    constructor (destructible, write, format, interval) {
        this._write = write
        this._entries = []
        this._format = format
        const isochronous = new Isochronous(interval, true, this._check.bind(this))
        destructible.durable('isochronous', isochronous.start())
        destructible.destruct(() => isochronous.stop())
        destructible.destruct(() => this._log(this._entries.splice(0)))
    }

    log (entry) {
        this._entries.push(entry)
    }

    push (envelope) {
        this._entries.push.apply(this._entries, envelope.entries)
    }

    _log (entries) {
        if (entries.length != 0) {
            this._write.call(null, entries.map(this._format).join('\n'))
        }
    }

    _check (status) {<commit_msg>Give entries a final sort.<commit_after>const ascension = require('ascension')
const sort = ascension([ Number ], entry => entry.when)

const Isochronous = require('isochronous')

class Printer {
    constructor (destructible, write, format, interval) {
        this._write = write
        this._entries = []
        this._format = format
        const isochronous = new Isochronous(interval, true, this._check.bind(this))
        destructible.durable('isochronous', isochronous.start())
        destructible.destruct(() => isochronous.stop())
        destructible.destruct(() => {
            this._entries.sort(sort)
            this._log(this._entries.splice(0))
        })
    }

    log (entry) {
        this._entries.push(entry)
    }

    push (envelope) {
        this._entries.push.apply(this._entries, envelope.entries)
    }

    _log (entries) {
        if (entries.length != 0) {
            this._write.call(null, entries.map(this._format).join('\n'))
        }
    }

    _check (status) {
{'fraction_non_alphanumeric': 0.1368801652892562, 'fraction_numerical': 0.002066115702479339, 'mean_word_length': 2.6205607476635513, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '1660578', 'n_tokens_mistral': 592, 'n_tokens_neox': 576, 'n_words': 109}