Skip to content

Accept URL as filename #109

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
fisker opened this issue Feb 17, 2025 · 2 comments
Open

Accept URL as filename #109

fisker opened this issue Feb 17, 2025 · 2 comments
Labels
enhancement New feature or request

Comments

@fisker
Copy link

fisker commented Feb 17, 2025

const pool = new Tinypool({
-  filename: new URL('./worker.mjs', import.meta.url).href,
+  filename: new URL('./worker.mjs', import.meta.url),
})
  1. Convenient to use
  2. Align with Worker constructor
@AriPerkkio
Copy link
Member

This should be doable, as child_process.fork() also supports it: https://nodejs.org/api/child_process.html#child_processforkmodulepath-args-options

Though we'll need to make sure it works on Windows too, as we've had URL issues there before.

@AriPerkkio AriPerkkio added the enhancement New feature or request label Feb 19, 2025
@fisker
Copy link
Author

fisker commented Feb 19, 2025

I was thinking change

this.filename = filename

to

this.filename = filename instanceof URL ? filename.href : filename

I don't think it related to Node.js API support

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants