Throttled parallel function invocation.
breeze-queue is available on npm.
$ npm install breeze-queue
breeze-queue is available as a component.
$ component install qualiancy/breeze-queue
The queue mechanism allows for a any number of data objects to be processed by an iterator when they become available. The queue will processes items in parellel, up to a given concurrently value, then will wait until an item has finished until beginning to process the next. The items queued can have a callback executed when it has completed its iterator.
In addition, a queue may also have
functions attached to listen for specific events.
On such event is an error. Should any item in the queue
fail to process and provide an error to it's
callback, no further items will be processed.
var Queue = ;var queue =;
Property indicating the number of items current in the queue. An item is removed from this list prior to being processed.
You can push an item or an array of items into
the queue for processing. The callback will be
called for the completion of each item if the queue
has not entered into an error state. A
boolean my also be provided if you wish to start
processing the queue with this push of items. If
no pushes provide the autostart, then the queue
must be started manually with
Note that if the queue has already been started but
has been drained of items, it will not start again
with another push unless the
autostart toggle is present.
// single itemqueue;// multiple itemsqueue;// notify callbackqueue;// autostartqueue;// notify + autostartqueue;
Begin the queue processing cycle. Has no impact if the queue is already processing.
Setting this to a function will provide a listener should an error occur. It will not be executed otherwise.
This listener will be executed when the number of queued items exceeds the current concurrency value. This will be executed directly after the push of said items.
This listener will be executed when the queue is empty. In other words, prior to the last item in the queue being processed.
This listener will be executed when all queued items have been executed through the iterator.
(The MIT License)
Copyright (c) 2012 Jake Luer firstname.lastname@example.org (http://qualiancy.com)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.