The following program works, but if we remove the compiler and runtime settings, it does not:
<html>
<body>
<script src="../../stopify/dist/stopify-full.bundle.js"></script>
<script>
function sleep(duration) {
asyncRun.pauseImmediate(() => {
window.setTimeout(
() => asyncRun.continueImmediate({ type: 'normal', value: undefined }),
duration);
});
}
const program = `
while(true) {
sleep(1000);
document.body.appendChild(document.createTextNode("."));
}
`;
const asyncRun = stopify.stopifyLocally(program, {}, {
estimator: "exact",
yieldInterval: 200
});
asyncRun.g = { sleep, document, window, asyncRun };
asyncRun.run(() => { });
window.setTimeout(() => {
asyncRun.pause(() => {
document.body.appendChild(document.createTextNode("paused"));
});
}, 3000);
</script>
</body>
</html>
The following program works, but if we remove the compiler and runtime settings, it does not: