<commit_before>'use strict';

// Should be idempotent.

module.exports = function(style) {
    var k;

    style.version = 5;

    var sources = style.sources;
    for (k in sources) {
        var source = sources[k];
        rename(source, 'minZoom', 'minzoom');
        rename(source, 'maxZoom', 'maxzoom');

        if (source.url && !source.url.match(/^mapbox:\/\//)) {
            source.tiles = [source.url];
            delete source.url;
        }
    }

    var layers = style.layers;
    for (k in layers) {
        var layer = layers[k];

        for (var classname in layer) {
            if (classname.indexOf('style') === 0) {
                var klass = layer[classname];
                rename(klass, 'raster-fade', 'raster-fade-duration');

                for (var p in klass) {
                    var match = p.match(/^transition-(.*)$/);
                    if (match) {
                        rename(klass, match[0], match[1] + '-transition');
                    }
                }
            }
        }
    }

    return style;
};

function rename(o, from, to) {
    if (from in o) {
        o[to] = o[from];
        delete o[from];
    }
}<commit_msg>Migrate Mapbox glyphs URL<commit_after>'use strict';

// Should be idempotent.

module.exports = function(style) {
    var k;

    style.version = 5;

    var sources = style.sources;
    for (k in sources) {
        var source = sources[k];
        rename(source, 'minZoom', 'minzoom');
        rename(source, 'maxZoom', 'maxzoom');

        if (source.url && !source.url.match(/^mapbox:\/\//)) {
            source.tiles = [source.url];
            delete source.url;
        }
    }

    if (style.glyphs === 'https://mapbox.s3.amazonaws.com/gl-glyphs-256/{fontstack}/{range}.pbf') {
        style.glyphs = 'mapbox://fontstack/{fontstack}/{range}.pbf';
    }

    var layers = style.layers;
    for (k in layers) {
        var layer = layers[k];

        for (var classname in layer) {
            if (classname.indexOf('style') === 0) {
                var klass = layer[classname];
                rename(klass, 'raster-fade', 'raster-fade-duration');

                for (var p in klass) {
                    var match = p.match(/^transition-(.*)$/);
                    if (match) {
                        rename(klass, match[0], match[1] + '-transition');
                    }
                }
            }
        }
    }

    return style;
};

function rename(o, from, to) {
    if (from in o) {
        o[to] = o[from];
        delete o[from];
    }
}
{'fraction_non_alphanumeric': 0.1534536891679749, 'fraction_numerical': 0.004709576138147566, 'mean_word_length': 1.5388446215139442, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 1, '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': '300279', 'n_tokens_mistral': 824, 'n_tokens_neox': 782, 'n_words': 180}