Scope of change:
I added a throttle method using Asyncrify. there are some caveats though
Key File
promises.ts
Notes
currently asyncrify is designed around callbacks, not returns. I had to do some promiseJitsu to keep the Promise<T[]> format for the return value. at the moment I create a new array of promises that handles the callback of asyncrify. these promises are not throttled, but the promises being passed to the throttle method is.
Tricks to help performance with this workaround:
using an array with a predefined length helps the garbage collector not create a new array on every.push and cleanup the old array.
Downsides to this approach:
Nested promises is always a code smell.
possible fixes:
I created an issue log for a feature request in asyncrify to support array inputs as well as returns.
Scope of change: I added a throttle method using Asyncrify. there are some caveats though Key File promises.ts Notes currently asyncrify is designed around callbacks, not returns. I had to do some promiseJitsu to keep the
Promise<T[]>
format for the return value. at the moment I create a new array of promises that handles the callback of asyncrify. these promises are not throttled, but the promises being passed to the throttle method is. Tricks to help performance with this workaround: using an array with a predefined length helps the garbage collector not create a new array on every.push and cleanup the old array. Downsides to this approach: Nested promises is always a code smell. possible fixes: I created an issue log for a feature request in asyncrify to support array inputs as well as returns.