State machines support added to JavaScript generator