<commit_before>'use strict';
/*
 * @author Nektro (<NAME>)
 * Copyright (c) 2017
 */
class Router {
    constructor(r, ops) {
        const options = Object.assign({}, {pages:[], extension:'.html'}, ops || {});
        this.root = r;
        this.pages = options.pages;
        this.pages.push('/');
        this.cache = new Map();
        this.extension = options.extension;
        this.element = document.body;
        window.addEventListener('hashchange', (e) => {
            this.gotoPage(e.newURL.substring(e.newURL.indexOf('#') + 1));
        });
    }
    resolveFileName(rt) {
        if (this.pages.indexOf(rt) > -1) return [`${rt}${this.extension}`];
    }
    getFileName(pn) {
        if (pn === '/') return Promise.resolve([`/index${this.extension}`]);
        let rsn = this.resolveFileName(pn);
        if (rsn !== undefined) return Promise.resolve(rsn);
        return Promise.resolve([`/blank${this.extension}`]);
    }
    processFile(src) {
        return src;
    }
    getPageContent(p) {
        return this.getFileName(p).then((pl) => {
            if (this.cache.has(pl[0])) {
                return Promise.resolve([this.cache.get(pl[0]),pl[1]]);
            }
            else {
                return fetch(`${this.root}/pages${pl[0]}`).then((x) => { return x.text() }).then((x) => {
                    let file = this.processFile(x);
                    if (!(this.cache.has(pl[0]))) this.cache.set(pl[0], file);
                    return Promise.resolve([file,pl[1]]);
                });
            }
        });
    }
    gotoPage(pn) {
        this.getPageContent(pn).then((x) => {<commit_msg>removed pages option, searches FS by default<commit_after>'use strict';
/*
 * @author Nektro (<NAME>)
 * Copyright (c) 2017
 */
class Router {
    constructor(r, ops) {
        const options = Object.assign({}, {extension:'.html'}, ops || {});
        this.root = r;
        this.cache = new Map();
        this.extension = options.extension;
        this.element = document.body;
        window.addEventListener('hashchange', (e) => {
            this.gotoPage(e.newURL.substring(e.newURL.indexOf('#') + 1));
        });
    }
    resolveFileName(rt) {
        return [rt];
    }
    getFileName(pn) {
        let rsn = this.resolveFileName(pn);
        if (rsn !== undefined) return Promise.resolve(rsn);
        return Promise.resolve([`/blank`]);
    }
    processFile(src) {
        return src;
    }
    getPageContent(p) {
        return this.getFileName(p).then((pl) => {
            if (this.cache.has(pl[0])) {
                return Promise.resolve([this.cache.get(pl[0]),pl[1]]);
            }
            else {
                return fetch(`${this.root}/pages${pl[0]}${this.extension}`)
                    .then((x) => {
                        if (x.status === 200) return x.text();
                        else return this.getPageContent([`/blank`]);
                    })
                    .then((x) => {
                    let file = this.processFile(x);
                    if (!(this.cache.has(pl[0]))) this.cache.set(pl[0], file);
                    return Promise.resolve([file,pl[1]]);
                });
            }
        });
    }
    gotoPage(pn) {
        this.getPageContent(pn).then((x) => {
{'fraction_non_alphanumeric': 0.1800061330880098, 'fraction_numerical': 0.008586323213738117, 'mean_word_length': 1.814495254529767, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 16, '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': '292748', 'n_tokens_mistral': 1005, 'n_tokens_neox': 973, 'n_words': 166}