Skip to content

Commit

Permalink
Check in dist for 1.0.2 release
Browse files Browse the repository at this point in the history
  • Loading branch information
eonarheim committed Mar 5, 2016
1 parent d3e4879 commit dcdaff9
Show file tree
Hide file tree
Showing 14 changed files with 220 additions and 209 deletions.
5 changes: 5 additions & 0 deletions README.md
Expand Up @@ -42,6 +42,11 @@ fsm.from(Elevator.DoorsClosed).to(Elevator.Moving);
// When the elevator reaches its destination, it may stop moving
fsm.from(Elevator.Moving).to(Elevator.DoorsClosed);

// Check that the current state is the initial state
if(fsm.is(Elevator.DoorsOpened)){
console.log("The doors are open Dave");
}


// Test validity of transitions from the current state, in this case 'Elevator.DoorsOpened'
fsm.canGo(Elevator.DoorsClosed); // returns true
Expand Down
4 changes: 2 additions & 2 deletions bower.json
@@ -1,12 +1,12 @@
{
"name": "typestate",
"version": "1.0.1",
"version": "1.0.2",
"homepage": "https://github.com/eonarheim/TypeState",
"authors": [
"Erik Onarheim"
],
"description": "A small finite state machine implementation in TypeScript.",
"main": "dist/typestate-1.0.1.js",
"main": "dist/typestate-1.0.2.js",
"keywords": [
"Finite",
"State",
Expand Down
Binary file removed dist/TypeState.1.0.1.nupkg
Binary file not shown.
Binary file added dist/TypeState.1.0.2.nupkg
Binary file not shown.
1 change: 0 additions & 1 deletion dist/typestate-1.0.1.js.map

This file was deleted.

4 changes: 0 additions & 4 deletions dist/typestate-1.0.1.min.js

This file was deleted.

88 changes: 41 additions & 47 deletions dist/typestate-1.0.1.d.ts → dist/typestate-1.0.2.d.ts
@@ -1,35 +1,41 @@
declare module TypeState {
/**
* Transition grouping to faciliate fluent api
* @class Transitions<T>
*/
class Transitions<T> {
fsm: FiniteStateMachine<T>;
constructor(fsm: FiniteStateMachine<T>);
fromStates: T[];
toStates: T[];
/**
* Specify the end state(s) of a transition function
* @method to
* @param ...states {T[]}
*/
* Specify the end state(s) of a transition function
*/
to(...states: T[]): void;
/**
* Specify that any state in the state enum is value
* Takes the state enum as an argument
*/
toAny(states: any): void;
}
/**
* Internal representation of a transition function
* @class TransitionFunction<T>
*/
class TransitionFunction<T> {
fsm: FiniteStateMachine<T>;
from: T;
to: T;
constructor(fsm: FiniteStateMachine<T>, from: T, to: T);
}
/***
/**
* Creates a hierarchical state machine, which allows the nesting of states in a super state, usefule
* for modeling more complicated behaviors than with just FSMs
* Please refer to https://en.wikipedia.org/wiki/UML_state_machine
*/
class HierarchicalStateMachine {
}
/**
* A simple finite state machine implemented in TypeScript, the templated argument is meant to be used
* with an enumeration.
* @class FiniteStateMachine<T>
*/
class FiniteStateMachine<T> {
currentState: T;
Expand All @@ -38,68 +44,56 @@ declare module TypeState {
private _onCallbacks;
private _exitCallbacks;
private _enterCallbacks;
/**
* @constructor
* @param startState {T} Intial starting state
*/
private _invalidTransitionCallback;
constructor(startState: T);
addTransitions(fcn: Transitions<T>): void;
/**
* Listen for the transition to this state and fire the associated callback
* @method on
* @param state {T} State to listen to
* @param callback {fcn} Callback to fire
*/
* Listen for the transition to this state and fire the associated callback
*/
on(state: T, callback: (from?: T) => any): FiniteStateMachine<T>;
/**
* Listen for the transition to this state and fire the associated callback, returning
* false in the callback will block the transition to this state.
* @method on
* @param state {T} State to listen to
* @param callback {fcn} Callback to fire
*/
* Listen for the transition to this state and fire the associated callback, returning
* false in the callback will block the transition to this state.
*/
onEnter(state: T, callback: (from?: T) => boolean): FiniteStateMachine<T>;
/**
* Listen for the transition to this state and fire the associated callback, returning
* false in the callback will block the transition from this state.
* @method on
* @param state {T} State to listen to
* @param callback {fcn} Callback to fire
*/
* Listen for the transition to this state and fire the associated callback, returning
* false in the callback will block the transition from this state.
*/
onExit(state: T, callback: (to?: T) => boolean): FiniteStateMachine<T>;
/**
* Declares the start state(s) of a transition function, must be followed with a '.to(...endStates)'
* @method from
* @param ...states {T[]}
*/
* List for an invalid transition and handle the error, returning a falsy value will throw an
* exception, a truthy one will swallow the exception
*/
onInvalidTransition(callback: (from?: T, to?: T) => boolean): FiniteStateMachine<T>;
/**
* Declares the start state(s) of a transition function, must be followed with a '.to(...endStates)'
*/
from(...states: T[]): Transitions<T>;
fromAny(states: any): Transitions<T>;
private _validTransition(from, to);
/**
* Check whether a transition to a new state is valide
* @method canGo
* @param state {T}
*/
* Check whether a transition to a new state is valid
*/
canGo(state: T): boolean;
/**
* Transition to another valid state
* @method go
* @param state {T}
*/
* Transition to another valid state
*/
go(state: T): void;
/**
* This method is availble for overridding for the sake of extensibility.
* It is called in the event of a successful transition.
* @method onTransition
* @param from {T}
* @param to {T}
*/
onTransition(from: T, to: T): void;
/**
* Reset the finite state machine back to the start state, DO NOT USE THIS AS A SHORTCUT for a transition. This is for starting the fsm from the beginning.
* @method reset
*/
* Reset the finite state machine back to the start state, DO NOT USE THIS AS A SHORTCUT for a transition.
* This is for starting the fsm from the beginning.
*/
reset(): void;
/**
* Whether or not the current state equals the given state
*/
is(state: T): boolean;
private _transitionTo(state);
}
}

0 comments on commit dcdaff9

Please sign in to comment.