<commit_before>'use strict';

var BBPromise = require('bluebird');
var _ = require('underscore');
var core, Err;

function Autogen(uri, callback) {
    var self = this;
    BBPromise.try(function () {
        var query = core.normalizeUri(uri).query;
        core.checkType(query, 'mingen', 'zoom');
        self.mingen = query.mingen;
        core.checkType(query, 'maxgen', 'zoom');
        self.maxgen = query.maxgen;
        core.checkType(query, 'minstore', 'zoom');
        self.minstore = query.minstore;
        core.checkType(query, 'maxstore', 'zoom');
        self.maxstore = query.maxstore;
        core.checkType(query, 'storage', 'string', true);
        core.checkType(query, 'generator', 'string', true);
        return core.loadSource(query.storage);
    }).then(function (storage) {
        self.storage = storage;
        return core.loadSource(query.generator);
    }).then(function (generator) {
        self.generator = generator;
    }).return(this).nodeify(callback);
}

Autogen.prototype.getTile = function(z, x, y, callback) {
    var self = this;
    return self.storage
        .getTileAsync(z, x, y)
        .catch(function (err) {
            if ((self.mingen !== undefined && z < self.mingen) ||
                (self.maxgen !== undefined && z > self.maxgen) ||
                !core.isNoTileError(err)
            ) {
                throw err;
            }
            var p = self.generator.getTileAsync(z, x, y);
            if ((self.minstore === undefined || z >= self.minstore) && (self.maxstore === undefined || z <= self.maxstore)) {
                p = p.spread(function (tile, headers) {
                    return self.storage.putTileAsync(z, x, y, tile)
                        .catch(function (err) {
                            core.log('error', err); // log and ignore
                        }).return([tile, headers]);
                });
            }
            return p;
        }).nodeify(callback, {spread: true});
};

Autogen.prototype.getInfo = function(callback) {
    return this.storage.getInfo(callback);
};


Autogen.initKartotherian = function(cor) {
    core = cor;
    Err = core.Err;
    core.tilelive.protocols['autogen:'] = Autogen;
};

module.exports = Autogen;
<commit_msg>Fixed missing var<commit_after>'use strict';

var BBPromise = require('bluebird');
var _ = require('underscore');
var core, Err;

function Autogen(uri, callback) {
    var self = this;
    var query;
    BBPromise.try(function () {
        query = core.normalizeUri(uri).query;
        core.checkType(query, 'mingen', 'zoom');
        self.mingen = query.mingen;
        core.checkType(query, 'maxgen', 'zoom');
        self.maxgen = query.maxgen;
        core.checkType(query, 'minstore', 'zoom');
        self.minstore = query.minstore;
        core.checkType(query, 'maxstore', 'zoom');
        self.maxstore = query.maxstore;
        core.checkType(query, 'storage', 'string', true);
        core.checkType(query, 'generator', 'string', true);
        return core.loadSource(query.storage);
    }).then(function (storage) {
        self.storage = storage;
        return core.loadSource(query.generator);
    }).then(function (generator) {
        self.generator = generator;
    }).return(this).nodeify(callback);
}

Autogen.prototype.getTile = function(z, x, y, callback) {
    var self = this;
    return self.storage
        .getTileAsync(z, x, y)
        .catch(function (err) {
            if ((self.mingen !== undefined && z < self.mingen) ||
                (self.maxgen !== undefined && z > self.maxgen) ||
                !core.isNoTileError(err)
            ) {
                throw err;
            }
            var p = self.generator.getTileAsync(z, x, y);
            if ((self.minstore === undefined || z >= self.minstore) && (self.maxstore === undefined || z <= self.maxstore)) {
                p = p.spread(function (tile, headers) {
                    return self.storage.putTileAsync(z, x, y, tile)
                        .catch(function (err) {
                            core.log('error', err); // log and ignore
                        }).return([tile, headers]);
                });
            }
            return p;
        }).nodeify(callback, {spread: true});
};

Autogen.prototype.getInfo = function(callback) {
    return this.storage.getInfo(callback);
};


Autogen.initKartotherian = function(cor) {
    core = cor;
    Err = core.Err;
    core.tilelive.protocols['autogen:'] = Autogen;
};

module.exports = Autogen;

{'fraction_non_alphanumeric': 0.14945591827670443, 'fraction_numerical': 0.0, 'mean_word_length': 2.1408647140864714, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '7269523', 'n_tokens_mistral': 1345, 'n_tokens_neox': 1324, 'n_words': 281}