Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
@jcoreio/async-throttle
Advanced tools
throttle async and promise-returning functions. Other packages don't do it right.
throttle async and promise-returning functions. Other packages don't do it right.
npm install --save @jcoreio/async-throttle
import throttle from '@jcoreio/async-throttle'
function throttle<Args: Array<any>, Value>(
func: (...args: Args) => Promise<Value>,
wait: ?number,
options?: {
getNextArgs?: (current: Args, next: Args) => Args
}
): (...args: Args) => Promise<Value>;
Creates a throttled function that only invokes func
at most once per every wait
milliseconds, and also waits for the
Promise
returned by the previous invocation to finish (it won't invoke func
in parallel).
The promise returned by the throttled function will track the promise returned by the next invocation of func
.
If wait
is falsy, it is treated as 0, which causes func
to be invoked on the next tick afte the previous invocation
finishes.
By default, func
is called with the most recent arguments to the throttled function. You can change this with the
getNextArgs
option -- for example, if you want to invoke func
with the minimum of all arguments since the last
invocation:
const throttled = throttle(foo, 10, {
getNextArgs: ([a], [b]) => [Math.min(a, b)]
})
throttled(2)
throttled(1)
throttled(3)
// foo will be called with 1
// time passes...
throttled(4)
throttled(6)
throttled(5)
// foo will be called with 4
FAQs
throttle async and promise-returning functions. Other packages don't do it right.
The npm package @jcoreio/async-throttle receives a total of 6,450 weekly downloads. As such, @jcoreio/async-throttle popularity was classified as popular.
We found that @jcoreio/async-throttle demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.