<commit_before>
/**
 * Represents an Amazon WebService Simple Workflow Execution
 * @constructor
 */
var WorkflowExecution = exports.WorkflowExecution = function (swfClient, baseConfig) {
    this.swfClient = swfClient;
    this.baseConfig = baseConfig;
};

WorkflowExecution.prototype = {

    /**
     * Start a worfklow
     */
    start: function (config, cb) {

        var o = {}, k;

        for (k in this.baseConfig) {
            if (this.baseConfig.hasOwnProperty(k)) {
                o[k] = this.baseConfig[k];
            }
        }

        for (k in config) {
            if (config.hasOwnProperty(k)) {
                o[k] = config[k];
            }
        }

        if (!o.workflowId) {
            o.workflowId = String(Math.random()).substr(2);
        }

        this.workflowId = o.workflowId;

        this.swfClient.client.startWorkflowExecution(o, function (err, result) {
            cb(err, result ? result.runId : null);
        });
    },

    /**
     * Send a signal to the workflow execution
     */
    signal: function (config, cb) {

        var o = {}, k;
        o.domain = this.baseConfig.domain;
        o.workflowId = this.workflowId;

        for (k in config) {
            if (config.hasOwnProperty(k)) {
                o[k] = config[k];
            }
        }

        this.swfClient.client.signalWorkflowExecution(o, cb);
    },

    /**
     * Terminate the workflow execution
     */
    terminate: function (config, cb) {

        var o = {}, k;
        o.domain = this.baseConfig.domain;
        o.workflowId = this.workflowId;

        for (k in config) {
            if (config.hasOwnProperty(k)) {
                o[k] = config[k];
            }
        }

        this.swfClient.client.terminateWorkflowExecution(o, cb);
    },

    /**
     * Get the history for the workflow execution
     */
    getHistory: function (config, cb) {

        var o = {}, k;
        o.domain = this.baseConfig.domain;
        //o.execution = this.workflowId;

        for (k in config) {
            if (config.hasOwnProperty(k)) {<commit_msg>Remove duplicate code in WorkflowExecution<commit_after>
/**
 * Represents an Amazon WebService Simple Workflow Execution
 * @constructor
 */
var WorkflowExecution = exports.WorkflowExecution = function (swfClient, baseConfig) {
    this.swfClient = swfClient;
    this.baseConfig = baseConfig;
};

WorkflowExecution.prototype = {

    /**
     * Start a worfklow
     */
    start: function (config, cb) {

        var o = {}, k;

        for (k in this.baseConfig) {
            if (this.baseConfig.hasOwnProperty(k)) {
                o[k] = this.baseConfig[k];
            }
        }

        for (k in config) {
            if (config.hasOwnProperty(k)) {
                o[k] = config[k];
            }
        }

        if (!o.workflowId) {
            o.workflowId = String(Math.random()).substr(2);
        }

        this.workflowId = o.workflowId;

        this.swfClient.client.startWorkflowExecution(o, function (err, result) {
            cb(err, result ? result.runId : null);
        });
    },

    _prepare_options: function(config) {
        var o = {}, k;
        o.domain = this.baseConfig.domain;
        o.workflowId = this.workflowId;

        for (k in config) {
            if (config.hasOwnProperty(k)) {
                o[k] = config[k];
            }
        }

        return o;
    },

    /**
     * Send a signal to the workflow execution
     */
    signal: function (config, cb) {
        var o = this._prepare_options(config);
        this.swfClient.client.signalWorkflowExecution(o, cb);
    },

    /**
     * Terminate the workflow execution
     */
    terminate: function (config, cb) {
        var o = this._prepare_options(config);
        this.swfClient.client.terminateWorkflowExecution(o, cb);
    },

    /**
     * Get the history for the workflow execution
     */
    getHistory: function (config, cb) {

        var o = {}, k;
        o.domain = this.baseConfig.domain;
        //o.execution = this.workflowId;

        for (k in config) {
            if (config.hasOwnProperty(k)) {
{'fraction_non_alphanumeric': 0.12372634643377002, 'fraction_numerical': 0.00048520135856380397, 'mean_word_length': 1.7340848806366047, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '4593705', 'n_tokens_mistral': 1270, 'n_tokens_neox': 1230, 'n_words': 273}