Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix FiniteStateMachine #2636

Merged
merged 1 commit into from
Mar 18, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 1 addition & 19 deletions src/finite-state-machine.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,6 @@

import {assert} from './asserts';

/**
* Sanitizes commas into an escaped form
* @param {*} value
*/
function stringSanitizer(value) {
return String(value).replace(/,/g, '\\,');
}

/**
* @template STATE
*/
Expand All @@ -41,13 +33,6 @@ export class FiniteStateMachine {
*/
this.state_ = initialState;

/**
* The bits of state that may change.
* @type {!Array<string>}
*/
this.bits_ = Object.keys(initialState);
assert(this.bits_.length > 0, 'must pass an initialState object');

/**
* Callbacks that are invoked when transitioning from an old state
* to the new.
Expand Down Expand Up @@ -97,9 +82,6 @@ export class FiniteStateMachine {
* @return {string}
*/
statesToTransition_(oldState, newState) {
const oldBits = this.bits_.map(bit => stringSanitizer(oldState[bit]));
const newBits = this.bits_.map(bit => stringSanitizer(newState[bit]));

return `${oldBits}|${newBits}`;
return `${oldState}|${newState}`;
}
}