A queue-flow constructor function like sloppy-queue-flow, but less sloppy!
npm install parallel-queue-flow
|16||downloads in the last month|
|Version||0.2.1 last updated 11 months ago|
|Keywords||queue-flow, queueflow, flow, queues, async, parallel, parallel-queue-flow|
|Dependencies||is-async, async-cancelable-events, queue-flow|
Like sloppy-queue-flow, but better!
This is like sloppy-queue-flow, but unlike sloppy-queue-flow, parallel-queue-flow lets you specify how many concurrent calls you want at a time (perhaps limit it to 4 calls per step), and it keeps queue ordering intact, so you can be sure reducing functions like
toArray always return the same results for a given data set no matter what kind of reducer function you provide it (with sloppy-queue-flow,
toArray is effectively broken, and
reduce only works with commutative functions).
For details on how to use queue-flow generally, see the main queue-flow website.
parallel-queue-flow is a replacement constructor function for queue-flow, and to use in Node.js code, simply:
var q = require('queue-flow'); var parallel = require('parallel-queue-flow'); q('parallelQueue', parallel(4)) ... //Your code here
parallel is a function that returns a constructor that runs your queue with the specified level of parallelism. If you pass in the function directly without calling it, instead it will create a "greedy" parallel queue that enqueues all incoming data to be processed immediately just like sloppy-queue-flow, but keeps track of queue ordering.
Copyright (C) 2012 by David Ellis
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.