jssm
Version:
A Javascript state machine with a simple API. Well tested, and typed with Flowtype. MIT License.
39 lines (25 loc) • 1.68 kB
HTML
<html>
<head>
<link rel="stylesheet" type="text/css" href="./style.css" />
<style type="text/css">
h1 { margin: 0; padding: 0 0 1em 0; font-size: 150%; }
html, body { margin: 0; padding: 0; border: 0; }
body { padding: 2em; line-height: 135%; }
code { font-size: 120%; padding: 0 0.25em; background-color: #eee; }
kbd { font-size: 115%; padding: 0 0.25em; background-color: #ddd; }
</style>
<script defer type="text/javascript" src="../../build/jssm.es5.cjs.js"></script>
<script defer type="text/javascript">
/* eslint-disable */
let jssm, sm;
window.onload = () => {
jssm = require('jssm');
sm = jssm.sm;
document.body.innerHTML = `<h1>Ready</h1><p>JSSM has now been loaded at version ${jssm.version}, and is bound to the global <code>jssm</code> (aka <code>window.jssm</code>.) Also, the state machine template string tag is exposed as <code>sm</code> (aka <code>window.sm</code>).</p><p>Please open a console and type something like</p><p><code>var traffic_light = sm<b>\` off -> red => green => yellow => red; [red yellow green] ~> off; \`</b>;</code></p><p>Now you have a working state machine to play with:</p><pre>> traffic_light.state();\n"off"\n\n> traffic_light.transition("green");\nfalse\n\n> traffic_light.state();\n"off"\n\n> traffic_light.transition("red");\ntrue\n\n> traffic_light.state();\n"red"</pre><p>Consoles are <kbd>f12</kbd> on Windows and Linux PCs, or <kbd>command-option-j</kbd> on Macs.</p>`;
}
/* eslint-enable */
</script>
</head>
<body>Loading…</body>
</html>