state-pattern.js