/continuation

Delimited Continuations for JavasScript

Primary LanguageTypeScript

Continuation

Delimited continuations for JavaScript

Install

Synopsis

//deno
import { evaluate } from "https://deno.land/x/continuation/mod.ts";
//npm
import { evaluate } from "@frontside/continuation";

evaluate(function* () {
  for (let i = 5; i > 0; i--) {
    console.log(`${i}...`);
    yield* shift(function* (resume) {
      setTimeout(resume, 1000);
    });
  }
  console.log("blast off!");
});

prints:

5...
4...
3...
2...
1...
blast off!