<commit_before>const dataviews = require('./');

module.exports = class DataviewFactory {
    static get dataviews() {
        return Object.keys(dataviews).reduce((allDataviews, dataviewClassName) => {
            allDataviews[dataviewClassName.toLowerCase()] = dataviews[dataviewClassName];
            return allDataviews;
        }, {});
    }

    static getDataview (query, dataviewDefinition) {
        const type = dataviewDefinition.type;
        if (!this.dataviews[type]) {
            throw new Error('Invalid dataview type: "' + type + '"');
        }
        return new this.dataviews[type](query, dataviewDefinition.options, dataviewDefinition.sql);
    }
};<commit_msg>Use destructuring assignment to improve readability<commit_after>const dataviews = require('./');

module.exports = class DataviewFactory {
    static get dataviews() {
        return Object.keys(dataviews).reduce((allDataviews, dataviewClassName) => {
            allDataviews[dataviewClassName.toLowerCase()] = dataviews[dataviewClassName];
            return allDataviews;
        }, {});
    }

    static getDataview (query, dataviewDefinition) {
        const { type, options, sql } = dataviewDefinition;

        if (!this.dataviews[type]) {
            throw new Error('Invalid dataview type: "' + type + '"');
        }

        return new this.dataviews[type](query, options, sql);
    }
};
{'fraction_non_alphanumeric': 0.12346570397111914, 'fraction_numerical': 0.0, 'mean_word_length': 3.017391304347826, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '4539428', 'n_tokens_mistral': 418, 'n_tokens_neox': 419, 'n_words': 79}