mcollina / async-cache-dedupe

Async cache with dedupe support
MIT License
612 stars 39 forks source link

Only use setImmediate if it is defined #137

Closed jmaroeder closed 7 months ago

jmaroeder commented 7 months ago

This PR changes the strategy used to determine if setImmediate is available, which should allow the library to work correctly on other non-Node runtimes such as cloudflare workers.

Fixes #136

jmaroeder commented 7 months ago

could you add some sort of test to verify it works correctly there?

Possibly, though it may involve a lot of extra setup/dependencies. I can look into it more soon, probably early next week

jmaroeder commented 7 months ago

@mcollina I've added a test that uses wrangler, which is the documented way to use the workerd runtime in tests. I also verified that it failed this test when running with the original implementation in storage/memory.js, and it passes now.