tinylibs / tinylet

🎨 redlet(), greenlet(), bluelet(), and more threading helpers for web Workers
MIT License
34 stars 0 forks source link

Does `console.log` work within `greenlet`? #6

Open tommy-mitchell opened 11 months ago

tommy-mitchell commented 11 months ago

I'm not sure if this is a limitation of this library or of Workers in general, but I was expecting the following code to log each index:

import { greenlet } from "tinylet";

const func = greenlet(() => {
    let count = 0;

    for (let i = 0; i < 1000; i++) {
        count = i + 1;
        console.log(`Item: ${i}`);
    }

    return count;
});

const count = await func();
console.log({ count });

However, the actual output is:

Item: 0
{ count: 1000 }

Why does it only log inside of the worker once?