
Research
Malicious npm Packages Impersonate Flashbots SDKs, Targeting Ethereum Wallet Credentials
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
throttle-wait
Advanced tools
Run a function at max once per x milliseconds. Subsequent calls will wait.
Run a function at max once per x milliseconds. Subsequent calls will wait.
$ npm install throttle-wait
or
$ yarn add throttle-wait
import { throttle } from 'throttle-wait'
function myFn() {
console.log(new Date())
}
const myFnThrottled = throttle(5 * 1000, myFn) // 5s
// 2020-01-01T00:00:00.114Z
await myFnThrottled()
// 2020-01-01T00:00:05.120Z
await myFnThrottled()
// 2020-01-01T00:00:10.125Z
await myFnThrottled()
import { Throttle } from 'throttle-wait'
class MyClass {
@Throttle(5 * 1000) // 5s
public async myFn() {
console.log(new Date())
}
}
const myClass = new MyClass()
// 2020-01-01T00:00:00.114Z
await myClass.myFn()
// 2020-01-01T00:00:05.120Z
await myClass.myFn()
// 2020-01-01T00:00:10.125Z
await myClass.myFn()
IMPORTANT: Make your function async. The decorator will return an async function. This will ensure that the intellisense of your IDE tells you that your function is async.
const myFnThrottled = throttle(throttleTime, myFn, {
max: 100,
onThrottle: (next, queue) => {
console.log(`Throttling, will run in ${next}ms (${queue} in the queue)`)
},
})
Throttle backpressure error: Throttle is being called faster than it can run
This means that your function is being called a lot asynchronously. An error is thrown when there are 100 calls in the queue (configurable).
If you want to ignore subsequent calls, look at lodash throttle function
If you want to have more throttling control, you can check out these great libs.
FAQs
Run a function at max once per x milliseconds. Subsequent calls will wait.
The npm package throttle-wait receives a total of 7 weekly downloads. As such, throttle-wait popularity was classified as not popular.
We found that throttle-wait demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.