-
Notifications
You must be signed in to change notification settings - Fork 0
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
[Milestone] v1 #1
Comments
Shall we change the name? @jcbhmr |
For the project itself? You can pick whatever name you want! 😊 I couldn't think of anything better than "tinythreadlet" on the spot when I made this thing 🤣 |
|
Sounds great! 🚀 |
Bun doesn't support workers yet. oven-sh/bun#901 |
@Aslemammad I can't access the Settings menu to add my NPM_TOKEN secret. Would you like to handle that, or how should I go about doing that? I've invited you on npmjs.com to be a "Maintainer" of the package: |
Heyyyy @jimmywarting! I notice you also made something similar to the redlet() function that I have in here. https://github.com/jimmywarting/await-sync If @Aslemammad is willing (I don't have access to the Settings tab) I think it'd be great to add you as a "collaborator" or whatever it's called (you don't have to though ❤️) since you seem to know a thing-or-two about worker sync SharedArrayBuffer magic. 😊 |
@jcbhmr I changed your access, try again now. |
I'm ok with adding Jimmy to the collaborators, in fact, I'd be happy. |
Hi, yes my await-sync pkg dose similar thing to I'm only going to comment on One key differences are that mine dose only allocated a fixed amount of SharedArrayBuffer and dose a little dance back and forth to kind of stream the data over to the other thread (sync) instead of using the grow method. (my tough was to be more memory friendly) so the receiver (caller) allocated a fixed amount of Uint8Array and the worker "writes" to it chunk-by-chunk. const buf2text = TextDecoder.prototype.decode.bind(new TextDecoder)
const deserialize = uint8 => JSON.parse(buf2text(uint8))
const get = awaitSync(async url => {
const res = await fetch(url)
const text = await res.arrayBuffer()
return new Uint8Array(text) // Must always return a Uint8Array
}, deserialize) // Optional deserialize function here as 2nd argument, otherwise it returns uint8arr
const json = get('https://httpbin.org/get') // JSON I found this: const f = redlet(async (u) => {
const response = await fetch(u);
return await response.json();
}) to be redundant to have to parse the response from uint8array -> text -> object -> text -> uint8array in the worker when it can just be passed over in a more direct approach instead. On the plus side it's more ergonomic. on the bad side it's less versatile to support other non-json stuff like a protobuf or file content or any kind of binary.
if it's about transferring functions argument then that is a peace of cake. for the return body it will be harder. the only thing that is going to support being transferable are the functions argument when you send a postMessage and order the worker to do work... they can be transfered over. but in get something that's a transferable object back from a return statement in a sync manner would be to use the NodeJS specific |
Make sure it works in Bunthis
too, or just arguments?The text was updated successfully, but these errors were encountered: