<commit_before>define([], function () {
    'use strict';

    // This mixin requires Fossil.Mixins.Deferrable
    // It gives an object the ability to start, standby and stop.
    var Startable = {
        run: false,
        start: function () {
            if (this.run) {
                return false;
            }
            if (!this._firstStarted) {
                this._firstStart();
                this._firstStarted = true;
            }
            // TODO enhance Deferrable/Startable to use a nested promise
            // so start is always called once start:fisrt is resolved and
            // upper level registered then handlers are executed after both
            // events.
            //
            // ```
            // app.on('start:first', function () {this.waitFor($.ajax(...));});
            // app.on('start', function () {this.waitFor($.ajax(...));});
            // app
            //     .start();
            //     .then(function() {/* should be called after both start:first and start */});
            // ```
            this._doStart();
            this.thenWith(this, null, this._startError);
        },
        standby: function () {
            if (!this.run) {
                return false;
            }
            this._doStandby();
        },
        stop: function () {
            if (!this._firstStarted) {
                return false;
            }
            this.standby();
            this.thenWith(this, this._doStop, this._stopError);
        },

        // Start being asynchronous, use this
        // callback to catch start errors.
        // when an error occurs, _doStart is not called,
        // this method is called instead.
        _startError: function (error) {
            throw error;
        },
        // Stop being asynchronous, use this
        // callback to catch stop errors.
        // When an error occurs, _doStop is not called,
        // this method is called instead.
        _stopError: function (error) {
            throw error;
        },

        _firstStart: function () {
            this.trigger('start:first', this);
        },
        _doStart: function () {
            this.trigger('start', this);
            this.run = true;
        },
        _doStandby: function () {
            this.trigger('standby', this);
            this.run = false;
        },
        _doStop: function () {
            this._firstStarted = false;
            this.trigger('stop', this);
        }
    };

    return Startable;
});<commit_msg>Fix #28.<commit_after>define([], function () {
    'use strict';

    // This mixin requires Fossil.Mixins.Deferrable
    // It gives an object the ability to start, standby and stop.
    var Startable = {
        run: false,
        start: function () {
            if (this.run) {
                return false;
            }
            this.run = true;
            if (!this._firstStarted) {
                this._firstStarted = true;
                this._firstStart();
            }
            // TODO enhance Deferrable/Startable to use a nested promise
            // so start is always called once start:fisrt is resolved and
            // upper level registered then handlers are executed after both
            // events.
            //
            // ```
            // app.on('start:first', function () {this.waitFor($.ajax(...));});
            // app.on('start', function () {this.waitFor($.ajax(...));});
            // app
            //     .start();
            //     .then(function() {/* should be called after both start:first and start */});
            // ```
            this._doStart();
            this.thenWith(this, null, this._startError);
        },
        standby: function () {
            if (!this.run) {
                return false;
            }
            this._doStandby();
        },
        stop: function () {
            if (!this._firstStarted) {
                return false;
            }
            this.standby();
            this.thenWith(this, this._doStop, this._stopError);
        },

        // Start being asynchronous, use this
        // callback to catch start errors.
        // when an error occurs, _doStart is not called,
        // this method is called instead.
        _startError: function (error) {
            throw error;
        },
        // Stop being asynchronous, use this
        // callback to catch stop errors.
        // When an error occurs, _doStop is not called,
        // this method is called instead.
        _stopError: function (error) {
            throw error;
        },

        _firstStart: function () {
            this.trigger('start:first', this);
        },
        _doStart: function () {
            this.trigger('start', this);
        },
        _doStandby: function () {
            this.trigger('standby', this);
            this.run = false;
        },
        _doStop: function () {
            this._firstStarted = false;
            this.trigger('stop', this);
        }
    };

    return Startable;
});
{'fraction_non_alphanumeric': 0.12145266918039294, 'fraction_numerical': 0.00039690414764834294, 'mean_word_length': 1.3300970873786409, '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': '4404973', 'n_tokens_mistral': 1302, 'n_tokens_neox': 1272, 'n_words': 361}