<commit_before>import * as SetOperations from './SetOperations';
import { IOperation } from './Interfaces';


export default class Dispatcher {
    /* TODO: this is not fully generalized. E.g. I don't have arguments here... */
    public static dispatch(program: string, args: string[]): Promise<string[]> {
        const operationSelector = Dispatcher.operationHash[program];

        /* Short-circuit */
        if (!operationSelector) {
            return Promise.reject({
                domain: 'Internal',
                reason: `Could not find ${program} in the set of supported operations.`,
                resolution: 'Either add a new supported operation or change the desired operation to a supported one.',
            });
        }

        const operation: IOperation = new operationSelector();

        return new Promise((resolve, reject) => {
            operation
                .parse(args)
                .then((data) => operation.run(data))
                .then((results) => resolve(results))
                .catch((error) => reject(error))
        })
    }

    private static operationHash: {[key: string]: any} = {
        fcat: SetOperations.Cat,
        funion: SetOperations.Union,
        fxor: SetOperations.XOR
    };

}<commit_msg>Need to remove the semicolon requirement...<commit_after>import * as SetOperations from './SetOperations';
import { IOperation } from './Interfaces';


export default class Dispatcher {
    /* TODO: this is not fully generalized. E.g. I don't have arguments here... */
    public static dispatch(program: string, args: string[]): Promise<string[]> {
        const operationSelector = Dispatcher.operationHash[program];

        /* Short-circuit */
        if (!operationSelector) {
            return Promise.reject({
                domain: 'Internal',
                reason: `Could not find ${program} in the set of supported operations.`,
                resolution: 'Either add a new supported operation or change the desired operation to a supported one.',
            });
        }

        const operation: IOperation = new operationSelector();

        return new Promise((resolve, reject) => {
            operation
                .parse(args)
                .then((data) => operation.run(data))
                .then((results) => resolve(results))
                .catch((error) => reject(error));
        });
    }

    private static operationHash: {[key: string]: any} = {
        fcat: SetOperations.Cat,
        funion: SetOperations.Union,
        fxor: SetOperations.XOR
    };

}
{'fraction_non_alphanumeric': 0.11565420560747663, 'fraction_numerical': 0.0, 'mean_word_length': 2.1444308445532436, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, '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': '2924374', 'n_tokens_mistral': 649, 'n_tokens_neox': 619, 'n_words': 201}