Óscar
Óscar
DDeno
Created by Óscar on 8/7/2024 in #help
Detect when the event loop is finished in a Worker
When Deno executes a script, once the script is finalized, the process is terminated. Is there any way to detect that inside a worker? I know I can call self.close() to terminate the worker, but I want to wait until all timers are closed (unawaited promises, etc) and the event loop is clean. Deno does it automatically in the main script, but I don't know if there's a way to detect this state inside a Worker.
4 replies
DDeno
Created by Óscar on 5/15/2023 in #help
What is the best way to count values with Deno.Kv?
I want to show the total values in the database. It seems that the only way is with kv.list() and then iterate the values. Probably this is not very performant if I only want to count the results. I'd like to have something like this:
const count = await kv.count(["users"]);

console.log(`There are ${count} users in the database`);
const count = await kv.count(["users"]);

console.log(`There are ${count} users in the database`);
3 replies
DDeno
Created by Óscar on 9/29/2022 in #help
Dynamic npm imports don't work
Hey there. It looks like dynamic imports don't work with npm specifiers. For example:
await import("npm:react")
Uncaught TypeError: Loading unprepared module: npm:react
at async <anonymous>:2:1
await import("npm:react")
Uncaught TypeError: Loading unprepared module: npm:react
at async <anonymous>:2:1
I din't see anything in the npm roadmap (https://github.com/denoland/deno/issues/15960) so I wonder if this is planned.
4 replies