Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
@riteable/q-worker
Advanced tools
Rate limit and queue async functions.
This module lets you queue up async tasks to be executed at a predetermined interval. For example, if you're working with a REST API that's rate limited, you can use this module to only execute requests X amount of times per second.
You can install using npm:
$ npm i @riteable/q-worker
const worker = require('q-worker')
const queue = worker({
delay: 1000,
concurrent: 1
})
function someAsyncTask () {
return new Promise((resolve) => {
setTimeout(() => resolve(new Date()), 100)
})
}
const task1 = queue.add(someAsyncTask)
const task2 = queue.add(someAsyncTask)
const task3 = queue.add(someAsyncTask)
Promise.all([task1, task2, task3])
.then(console.log)
.catch(console.error)
The console.log
would output something like the following:
[
2020-09-17T12:00:56.471Z,
2020-09-17T12:00:57.474Z,
2020-09-17T12:00:58.474Z
]
The output shows the timestamps are all 1 second (1000ms) apart, which is determined by the delay: 1000
setting.
If the concurrent
option is set to 2
, you might get something like this:
[
2020-09-17T12:04:15.035Z,
2020-09-17T12:04:15.035Z,
2020-09-17T12:04:16.038Z
]
The first two tasks are executed at the same time, but the third task is delayed by the delay
amount.
delay
: The amounts of milliseconds between tasks.concurrent
: The amount of tasks executed at the same time.Available on the configured object, eg.: queue.add()
.
add(fn)
: Add an async function to the queue.Available on the configured object, through the events
key, eg.: queue.events.on()
.
'done'
: Fired when all tasks are done executing.FAQs
Rate limit and queue async functions.
We found that @riteable/q-worker 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
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.