
Security News
/Research
Wallet-Draining npm Package Impersonates Nodemailer to Hijack Crypto Transactions
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
timer-queue
Advanced tools
TimerQueue is for controlling the execution timing of function
npm install timer-queue
Constructor
Object
- may contain inital valuesnumber
- interval time (ms) for execution. default: 0
number
- timeout time (ms) for execution. default: 0
number
- retry count when execution function failed. default: 0
number
- interval time (ms) for retry execution. default: 0
boolean
- auto start when enqueue by tqueue.push()
. default: false
boolean
- run immediately when queue is empty and enqueuing by tqueue.push()
. default: false
start the queue.
stop the queue.
can be resumed with tqueue.start()
and can be empty with tqueue.clear()
.
empty the queue.
enqueue the function.
function
- execution functionnumber
- delay time (ms) for execution. defalut: 0
enqueue the function.
function
- execution functionObject
- may contain options valuesnumber
- delay time (ms) for execution. defalut: 0
number
- retry count when execution function failed. default: 0
number
- interval time (ms) for retry execution. default: 0
function
- error callback.import TimerQueue from 'timer-queue'
let count = 0
const now = Date.now()
const tqueue = new TimerQueue({
interval: 1000,
timeout: 10000,
retry: 3,
retryInterval: 200,
autostart: false
})
tqueue.push(() => {
const result = count++ > 1
console.log(`first: ${Date.now() - now}ms / return ${result}`)
return result // return Boolean or not return
})
tqueue.push(() => {
count = 0 // reset counter
})
tqueue.push((done, error) => {
const result = count++ > 1
setTimeout(() => {
console.log(`second: ${Date.now() - now}ms / ${result ? 'done()' : 'error()'}`)
result ? done() : error() // execute a arguments callback
}, 0)
})
tqueue.push(() => {
count = 0 // reset counter
})
tqueue.push(() => {
const result = count++ > 1
const promise = new Promise((resolve, reject) => {
setTimeout(() => {
console.log(`third: ${Date.now() - now}ms / ${result ? 'resolve()' : 'reject()'}`)
result ? resolve() : reject(new Error('retry'))
}, 0)
})
return promise // return a promise
})
tqueue.on('end', () => {
console.log(`end: ${Date.now() - now}ms`)
})
tqueue.on('error', () => {
console.log(`error: ${Date.now() - now}ms`)
})
tqueue.start()
// => first: 3ms / return false
// => first: 212ms / return false
// => first: 414ms / return true
// => second: 2421ms / error()
// => second: 2625ms / error()
// => second: 2832ms / done()
// => third: 4841ms / reject()
// => third: 5046ms / reject()
// => third: 5250ms / resolve()
// => end: 5251ms
import TimerQueue from 'timer-queue'
const now = Date.now()
const tqueue = new TimerQueue({
interval: 1000,
timeout: 10000,
retry: 3,
retryInterval: 200,
autostart: false
})
tqueue.push(() => {
console.log(`first: ${Date.now() - now}ms / return false`)
return false
})
tqueue.push(() => {
console.log(`second: not execute`)
})
tqueue.on('end', () => {
console.log(`end: ${Date.now() - now}ms`)
})
tqueue.on('error', () => {
console.log(`error: ${Date.now() - now}ms`)
})
tqueue.start()
// => first: 4ms / return false
// => first: 211ms / return false
// => first: 419ms / return false
// => first: 623ms / return false
// => error: 624ms
# build
npm run build
# test
npm run test
MIT
FAQs
time-delayed function queue
The npm package timer-queue receives a total of 33 weekly downloads. As such, timer-queue popularity was classified as not popular.
We found that timer-queue 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.
Security News
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.