Following user feedback I've added some key "lodash" like functions to the out of the box features of js-coroutines.
I've added keyByAsync group...
For further actions, you may consider blocking this person and/or reporting abuse
Great collection! Thanks!
mean time, for the "keyBy" I played around with this.
That should certainly work! I'd just say inside this one function I'd avoid immutability - because nothing has access to the mutable object and it will allocate a lot less memory if you modify one thing rather than make a new one on each loop.
Certainly, and perhaps is significant on large data..
I put up something like this..:
and call it from useEffect from inside a hook...
For some reason I could not use the keyBy provided "out of the box". I think is a npm issue on my side
Odd on the "out of the box" all my tests seem to be ok. You probably don't want to yield that much. I'd be saying (if collection is an array) that you should yield every 32 or something using
It's a balance between checking often enough and slowing it down a lot by checking too much.
In more recent versions you can also just call
run()
on the result of executing the generator, in your example this simplified the second routine to be:npm version should be 2.3.62
It totally make sense!
Updated the npm as I was way behind... odd that I had to uninstall and then install again. Otherwise it was still version 1.1.36.
I hope that will not break the code now :)
Thanks for everything!
Right I added a breaking change a while ago, but it only affects a very small use case, so hopefully all ok. It was when I changed from using an external polyfill for
requestIdleCallback
to the new internal one.Updated an everything seems to work like a charm!
Still It seems that you forgot some "debugger" at keyBy in array-utilities.js.
(Should I have written on GitHub on that? if so sorry)
Ouch lol. Ooops. Fixing that.
2.3.63 - removed the
debugger
Is there any performance benefit using
parseAsync(response.text())
than the usualresponse.json()
?This is really situational, because
JSON.parse
is really fast. With small workloads you will measure it in tens of microseconds. But it does block the event loop.Agreed, parse is a lot faster than storage, but definitely can take more than 16.7ms with significant packets. You'd be trading performance for a smooth out, sometimes worth it with large packets. Should only be used if there is a glitch present I'd say.
If it was an option, I'd also consider using
ndjson
to split up the JSON objects into manageable chunks to get the best of both worlds.Yes, even though response.json() looks like it's async, it isn't. So parsing JSON is a lot faster than stringifying it, but if it was huge then this would help. Part of the reason for writing js-c was that I needed an async json.