
Security News
Django Joins curl in Pushing Back on AI Slop Security Reports
Django has updated its security policies to reject AI-generated vulnerability reports that include fabricated or unverifiable content.
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.
domUIQueue, // A Queue used for updating the DOM or other UI after
// state has settled, but before user tasks
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 queues = require("can-queues");
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
queues.batch.start();
this.handlers.notify.forEach((handler) => {
queues.notifyQueue.enqueue(handler, this, args, {log: [handler.name+" by "+this._cid]});
})
this.handlers.mutate.forEach((handler) => {
queues.mutateQueue.enqueue(handler, this, args, {log: [handler.name+" by "+this._cid]});
})
queues.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
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
Django has updated its security policies to reject AI-generated vulnerability reports that include fabricated or unverifiable content.
Security News
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
Security News
A new Node.js homepage button linking to paid support for EOL versions has sparked a heated discussion among contributors and the wider community.