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.
can-queues
Advanced tools
Exports an object with the following:
{
Queue, // The Queue type constructor
PriorityQueue, // The PriorityQueue type constructor
notifyQueue, // A Queue used to tell objects that
// derive a value that they should be updated.
deriveQueue, // A PriorityQueue used update values.
mutateQueue, // A Queue used to register tasks that might
// update other values.
batch: {
start, // A function used to prevent the automatic flushing
// of the NOTIFY_QUEUE.
stop // A function used to begin flushing the NOTIFY_QUEUE.
},
enqueueByQueue // A helper function used to queue a bunch of tasks.
stack,
logStack
}
If you want to implement an observable that complies with can-reflect
, and lets people
listen to events with .on
, you'll want the following:
var canSymbol = require("can-symbol");
var QUEUE = require("@bitovi/queue");
var observable = {
_cid: 123142123123,
value: undefined,
handlers: {
notify: [], mutate: []
},
[canSymbol.getKeyValue('can.onValue')]: function(handler, queueName) {
// save handlers by their queue
this.handlers[queueName].push(handler);
},
on: function(handler) {
// these handlers should always run last because they might mutate
this.handlers.mutate.push(handler);
},
[canSymbol.getKeyValue('can.setKeyValue')]: function(newValue) {
var args = [newValue, this.value]
this.value = newValue;
// start a batch so we don't .flush() the NOTIFY_QUEUE until everything has been added
QUEUE.batch.start();
this.handlers.notify.forEach((handler) => {
QUEUE.NOTIFY_QUEUE.enqueue(handler, this, args, {log: [handler.name+" by "+this._cid]});
})
this.handlers.mutate.forEach((handler) => {
QUEUE.MUTATE_QUEUE.enqueue(handler, this, args, {log: [handler.name+" by "+this._cid]});
})
QUEUE.batch.stop();
}
}
new Queue(name, [callbacks])
Creates a queue instance.
name
- the name of the queue used for logging.callbacks
- an object of optional callbacks like {onFirstTask: fn(), onComplete: fn()}
where:
onFirstTask
- is called when the first task is added to an empty queueonComplete
- is called when the queue is empty.queue.enqueue(fn, context, args, meta)
Enqueues the fn
function to be called with context
as this
and args
as its arguments.
// console.logs "say hi"
queue.enqueue(console.log, console, ["say hi"], {});
queue.flush();
meta
- An object used to give additional information. Current properties that might be used:
log
- An array of values that will be added to this task's debug output. (You'll often want [fn.name]
)queue.flush()
Runs all tasks in the queue.
new PriorityQueue(name, [callbacks])
A PriorityQueue works just like a normal queue. Except:
fn
to be enqueued at one time.meta.priority
.batch.start()
batch.stop()
FAQs
A light weight JavaScript task queue
The npm package can-queues receives a total of 1,671 weekly downloads. As such, can-queues popularity was classified as popular.
We found that can-queues demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 8 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.
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.