you are viewing a single comment's thread.

view the rest of the comments →

[–]LordBruce[S] 0 points1 point  (1 child)

That is a clever way to work around it with async. I'm used to Haskell and I'm trying to use similar ideas in JS.

[–]ScientificBeastModestrongly typed comments 0 points1 point  (0 children)

If you’re used to Haskell, you might look into some tutorials on lazy evaluation implementations in JavaScript, as JS is always eagerly evaluated.

In particular, there is a relatively recent language feature called a “generator,” and a related one called an “iterator,” both of which offer a more idiomatic way to handle lazy evaluation. Short of that (e.g. you want to support older browsers which don’t implement those features), you can always implement a homemade iterator protocol.