Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
kuyruk is a powerful asynchronous queue implementation for managing concurrency and controlling the flow of asynchronous tasks. It supports various modes, such as callbacks, promises, FIFO, LIFO, priority, factor and round-robin, providing flexibility for different use cases.
npm i kuyruk
'use strict';
const Kuyruk = require('kuyruk');
const queue = new Kuyruk({ concurrency: 3 });
queue
.success((result) => {
console.log(result);
})
.drain(() => {
console.log('all done!');
});
const someAsyncFn = (num) =>
new Promise((resolve) => {
setTimeout(() => {
resolve(num);
}, 0);
});
for (let i = 0; i < 10; i++) {
queue.add(() => someAsyncFn(i));
}
const Kuyruk = require('kuyruk');
const queue = new Kuyruk({ concurrency: 3 });
const someTaskOnCallback = (num, cb) => {
setTimeout(() => {
cb(null, num);
}, 0);
};
queue
.process(someTaskOnCallback)
.success((result) => {
console.log(result);
})
.drain(() => {
console.log('all done!');
});
for (let i = 0; i < 10; i++) {
queue.add(i);
}
const Kuyruk = require('kuyruk');
const queue = new Kuyruk({ concurrency: 3 });
const someAsyncTask = (num) => {
return new Promise((resolve) => {
setTimeout(() => {
resolve(num);
}, 0);
});
};
queue
.process(someAsyncTask)
.success((result) => {
console.log(result);
})
.drain(() => {
console.log('all done!');
});
for (let i = 0; i < 10; i++) {
queue.add(i);
}
debounceMode
). Tasks can be delayed and bundled to reduce the load on the system.priorityMode
), ensuring that critical tasks are processed first.roundRobinMode
), ensuring equal task distribution.processTimeout
) and waiting for tasks to be processed (waitTimeout
), allowing tasks to fail gracefully if they take too long.onProcess
: Define the logic for processing each task.onSuccess
: Callback for when a task completes successfully.onFailure
: Callback for when a task fails.onDone
: Executed after each task finishes, regardless of success or failure.onDrain
: Called when the queue has no more tasks to process.onTimeout
: Handle task timeout events.channels
static method to create multiple queues dynamically with predefined concurrency and size settings.factor
parameter, which can be helpful for task categorization or grouping.Kuyruk()
queue#add()
queue#pause()
queue#resume()
queue#clear()
queue#pipe()
queue#timeout()
queue#wait()
queue#debounce()
queue#process()
queue#done()
queue#success()
queue#failure()
queue#drain()
queue#fifo()
queue#lifo()
queue#priority()
queue#roundRobin()
Creates a new kuyruk instance.
Arguments:
concurrency
(optional): Number of tasks that can be processed simultaneously.size
(optional): Maximum number of tasks the queue can hold.Adds a task to the queue. If the queue is full or paused, the task will wait in the queue.
Arguments:
task
: The task to be processed, can be a function or any data type.factor
(optional): Used for round-robin processing.priority
(optional): Task priority, used when the queue is in priority mode.Pauses task processing. Tasks currently being processed will not be stopped, but new tasks won't be taken until resumed.
Resumes task processing after being paused. Tasks in the queue will be processed again.
Clears the queue of all waiting tasks and resets internal counters.
Pipes the result of the current queue to another queue. This will pass completed tasks from the current queue to the destination queue.
Arguments:
destinationQueue
: An instance of Kuyruk that will receive the results of completed tasks from the current queue. The tasks are passed to the destination queue for further processing or handling.Sets a timeout for each task in the queue. If a task takes longer than the specified time, it will be interrupted.
Arguments:
msec
: The time in milliseconds before a task times out.onTimeout
(optional): A function to call when a task times out.Sets a maximum wait time for tasks in the queue. If a task waits longer than this time without being processed, it will time out.
Arguments:
msec
: The maximum time in milliseconds a task can wait in the queue.Debounces task execution, ensuring that a certain number of tasks (count) are processed within a specific time interval.
Arguments:
count
: Number of tasks to process before applying the debounce delay.interval
: The time interval in milliseconds for the debounce effect.Defines the function that will process each task. The listener receives the task and a callback to signal completion.
Arguments:
listener
: The function responsible for processing each task.Sets a callback to be called when a task is finished (whether successful or failed).
Arguments:
listener
: The function to call when a task finishes, with arguments err and result.Defines a callback that is called when a task is successfully processed.
Arguments:
listener
: The function to call on success, with the task result.Defines a callback to handle failed tasks.
Arguments:
listener
: The function to call on failure, with the task error.Sets a function to be called when the queue has processed all tasks.
Arguments:
listener
: The function to call when the queue is drained.Sets the queue to FIFO (first-in-first-out) mode.
Sets the queue to LIFO (last-in-first-out) mode.
Enables or disables priority mode. When enabled, tasks with higher priority values will be processed first.
Arguments:
flag
: Boolean flag to enable or disable priority mode.Enables or disables round-robin mode. Tasks will be processed in a round-robin fashion based on their assigned factor.
Arguments:
flag
: Boolean flag to enable or disable round-robin mode.MIT
FAQs
Multifunctional Asynchronous Concurrent Queue
The npm package kuyruk receives a total of 8 weekly downloads. As such, kuyruk popularity was classified as not popular.
We found that kuyruk demonstrated a healthy version release cadence and project activity because the last version was released less than 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
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.