<commit_before>/*
 * Stately.js: A JavaScript based finite-state machine (FSM) engine.
 *
 * Copyright (c) 2012 <NAME> (<EMAIL>)
 * Released under MIT license.
 *
 * Version: 0.9.8
 *
 */
(function (exports) {

    //the state machine engine
    var Stately = (function (undefined) {

        var
            //helper to identify options type
            toString = Object.prototype.toString,

            //custom exception for invalid states
            InvalidStateError = (function () {

                //custom event constructor
                function InvalidStateError(message) {

                    //the error message
                    this.message = message;

                }

                //inherit from error object
                InvalidStateError.prototype = new Error();

                //return custom event
                return InvalidStateError;

            })();

        //constructor
        function Stately(statesObject) {

            //if statesObject is a function
            if (typeof(statesObject) === 'function') {

                //avaluate it
                statesObject = statesObject();

            }

            var
                //current state of the machine
                currentState,

                //storage for notification callbacks
                notificationStore = [],

                //notify callbacks about a transition
                notify = function () {

                    //make copy of notification storage
                    var notifications = notificationStore.slice();

                    //walk over stored callbacks
                    for (var i = 0, l = notifications.length; i < l; i++) {

                        //and notify them
                        notifications[i].apply(this, arguments);

                    }
                },

                //storage for machine states
                stateStore = {

                    //evaluates the current state
                    getMachineState: function getMachineState() {

                        //return current state as string
                        return currentState.name;

                    },

                    //function to transition into another state
                    setMachineState: function setMachineState(nextState) {

                        var
                            //leave state hook
                            onLeaveState,

                            //enter state hook
                            onEnterState,

                            //store last machine state
                            lastState = currentState;

                        //if state machine cannot handle returned state
                        if (!nextState || !nextState.name || !stateStore[nextState.name]) {

                            //throw invalid state exception
                            throw new InvalidStateError('Stately.js: Transitioned into invalid state: `' + setMachineState.caller + '`.');

                        }

                        //if state has changed
                        if (nextState !== currentState) {

                            //retrieve leave state hook
                            onLeaveState = stateMachine['onleave' + currentState.name];

                            //if a hook is attached
                            if (onLeaveState && typeof(onLeaveState) === 'function') {

                                //apply it
                                onLeaveState.call(stateStore, arguments[1], lastState.name, nextState.name);

                            }

                            //transition into next state
                            currentState = nextState;

                            //retrieve enter state hook
                            onEnterState = stateMachine['onenter' + currentState.name] || stateMachine['on' + currentState.name];

                            //if a hook is attached
                            if (onEnterState && typeof(onEnterState) === 'function') {

                                //apply it
                                onEnterState.call(stateStore, arguments[1], lastState.name, nextState.name);

                            }

                            //notify notification callbacks about transition
                            notify.call(stateStore, arguments[1], lastState.name, nextState.name);

                        }

                        //return the state store
                        return this;

                    }

                },

                //the state machine
                stateMachine = {

                    //copy function to public state machine object
                    getMachineState: stateStore.getMachineState,

                    //store a new notification callback
                    bind: function (callback) {

                        //if we have a new notification callback
                        if (callback) {

                            //store it in notification storage<commit_msg>Introduce getMachineEvents(), returning possible events for the current state.<commit_after>/*
 * Stately.js: A JavaScript based finite-state machine (FSM) engine.
 *
 * Copyright (c) 2012 <NAME> (<EMAIL>)
 * Released under MIT license.
 *
 * Version: 0.9.8
 *
 */
(function (exports) {

    //the state machine engine
    var Stately = (function (undefined) {

        var
            //helper to identify options type
            toString = Object.prototype.toString,

            //custom exception for invalid states
            InvalidStateError = (function () {

                //custom event constructor
                function InvalidStateError(message) {

                    //the error message
                    this.message = message;

                }

                //inherit from error object
                InvalidStateError.prototype = new Error();

                //return custom event
                return InvalidStateError;

            })();

        //constructor
        function Stately(statesObject) {

            //if statesObject is a function
            if (typeof(statesObject) === 'function') {

                //avaluate it
                statesObject = statesObject();

            }

            var
                //current state of the machine
                currentState,

                //storage for notification callbacks
                notificationStore = [],

                //notify callbacks about a transition
                notify = function () {

                    //make copy of notification storage
                    var notifications = notificationStore.slice();

                    //walk over stored callbacks
                    for (var i = 0, l = notifications.length; i < l; i++) {

                        //and notify them
                        notifications[i].apply(this, arguments);

                    }
                },

                //storage for machine states
                stateStore = {

                    //evaluates the current state
                    getMachineState: function getMachineState() {

                        //return current state as string
                        return currentState.name;

                    },

                    //function to transition into another state
                    setMachineState: function setMachineState(nextState) {

                        var
                            //leave state hook
                            onLeaveState,

                            //enter state hook
                            onEnterState,

                            //store last machine state
                            lastState = currentState;

                        //if state machine cannot handle returned state
                        if (!nextState || !nextState.name || !stateStore[nextState.name]) {

                            //throw invalid state exception
                            throw new InvalidStateError('Stately.js: Transitioned into invalid state: `' + setMachineState.caller + '`.');

                        }

                        //if state has changed
                        if (nextState !== currentState) {

                            //retrieve leave state hook
                            onLeaveState = stateMachine['onleave' + currentState.name];

                            //if a hook is attached
                            if (onLeaveState && typeof(onLeaveState) === 'function') {

                                //apply it
                                onLeaveState.call(stateStore, arguments[1], lastState.name, nextState.name);

                            }

                            //transition into next state
                            currentState = nextState;

                            //retrieve enter state hook
                            onEnterState = stateMachine['onenter' + currentState.name] || stateMachine['on' + currentState.name];

                            //if a hook is attached
                            if (onEnterState && typeof(onEnterState) === 'function') {

                                //apply it
                                onEnterState.call(stateStore, arguments[1], lastState.name, nextState.name);

                            }

                            //notify notification callbacks about transition
                            notify.call(stateStore, arguments[1], lastState.name, nextState.name);

                        }

                        //return the state store
                        return this;

                    },

                    //function returns the possible events in current state
                    getMachineEvents: function getMachineEvents() {

                        //storage for the events in current state
                        var events = [];

                        //walk over the events of the current state
                        for (property in currentState) {

                            //ensure to only walk over own properties
                            if (currentState.hasOwnProperty(property)) {

                                //if it is an event function
                                if (typeof(currentState[property]) === 'function') {

                                    //store it in events storage
                                    events.push(property);
                                }
                            }
                        }

                        //return the possible events
                        return events;
                    }

                },

                //the state machine
                stateMachine = {

                    //copy function to public state machine object
                    getMachineState: stateStore.getMachineState,

                    //copy function to public state machine object
                    getMachineEvents: stateStore.getMachineEvents,

                    //store a new notification callback
                    bind: function (callback) {

                        //if we have a new notification callback
                        if (callback) {

                            //store it in notification storage
{'fraction_non_alphanumeric': 0.0692287210437561, 'fraction_numerical': 0.0019526049525161978, 'mean_word_length': 1.0003550505947096, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7072611', 'n_tokens_mistral': 2338, 'n_tokens_neox': 2077, 'n_words': 684}