<commit_before>var tmp = require('tmp'),
    zip = require('./lib/zip'),
    epub = require('./lib/epub'),
    queue = require('./lib/queue'),

    init = function (root, cleanup, done) {
        return function (err) {
            if (err) {
                throw err
            }

            var book = epub(root),
                modifiers = queue(),
                runner = function (callable) {
                    return function (done) {
                        callable(book, done)
                    }
                },
                thrower = function (success, error) {
                    return function (err) {
                        if (err) {
                            if (error) {
                                error(err)
                            }
                            throw err
                        }
                        success()
                    }
                },

                instance = {
                    use: function (callable) {
                        modifiers.push(runner(callable))

                        return instance
                    },
                    save: function (file, done) {
                        modifiers.process(thrower(function () {

                            book.persist(thrower(function () {

                                zip.compress(root, file, thrower(function () {
                                    cleanup()
                                    if (done) {
                                        done()
                                    }
                                }))
                            }))
                        }))
                    }
                }

            done(instance)
        }
    }

module.exports = function (input, callback) {
    tmp.dir({unsafeCleanup: true, mode: 0750}, function (err, path, cleanup) {
        if (err) {
            throw err
        }

        zip.extract(input, path, init(path, cleanup, callback))
    });
}<commit_msg>improve naming<commit_after>var tmp = require('tmp'),
    zip = require('./lib/zip'),
    epub = require('./lib/epub'),
    queue = require('./lib/queue'),

    init = function (root, cleanup, callback) {
        return function (err) {
            if (err) {
                throw err
            }

            var book = epub(root),
                modifiers = queue(),
                runner = function (callable) {
                    return function (done) {
                        callable(book, done)
                    }
                },
                thrower = function (success, error) {
                    return function (err) {
                        if (err) {
                            if (error) {
                                error(err)
                            }
                            throw err
                        }
                        success()
                    }
                },

                instance = {
                    use: function (callable) {
                        modifiers.push(runner(callable))

                        return instance
                    },
                    save: function (file, done) {
                        modifiers.process(thrower(function () {

                            book.persist(thrower(function () {

                                zip.compress(root, file, thrower(function () {
                                    cleanup()
                                    if (done) {
                                        done()
                                    }
                                }))

                            }))

                        }))
                    }
                }

            callback(instance)
        }
    }

module.exports = function (input, callback) {
    tmp.dir({unsafeCleanup: true, mode: 0750}, function (err, path, cleanup) {
        if (err) {
            throw err
        }

        zip.extract(input, path, init(path, cleanup, callback))
    });
}
{'fraction_non_alphanumeric': 0.09483404042924881, 'fraction_numerical': 0.001996506114299975, 'mean_word_length': 0.7260981912144703, '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': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4831435', 'n_tokens_mistral': 917, 'n_tokens_neox': 820, 'n_words': 183}