Category "yield"

How to run event loop when doing nested/recursive computations?

The usual examples of how to break a computation and release using setTimeout() seem to rely on having a shallow (1-deep) call stack. But what about when you ar

How to convert a nested for of loop into a custom iterator?

I have the following code: function* getPossibleCollidersWith(shape) { for (let square of retrieve(shape)) { for (let neighbor of square) { yield ne

What is the return type hint of a generator function?

I'm trying to write a :rtype: type hint for a generator function. What is the type it returns? For example, say I have this functions which yields strings: d

check if function is a generator

I played with generators in Nodejs v0.11.2 and I'm wondering how I can check that argument to my function is generator function. I found this way typeof f ===