## NOTE: This documentation is ahead of the codebase.
npm install galactic.queue``js`
Galactic.queue(items, handler) // starts processing 1 queue item
Galactic.queue(items, handler, processes) // starts processing a specific number of queue items
`jsresults
Galactic.queue(items, (item, key, mapper) => {
mapper.reportProgress(0.25) // report current item progress
return // whatever you return here is stored in progress
return new Promise((resolve) => { // unless its a promise, in which case we wait for that to resolve
/ do something cool here /
}).catch(
mapper.reject
)
}).onProgress((progress, state, mapper) => { // is floating point 0.0—1.0results
state = [{key: key, value: item, progress: 1.0}]
state.forEach((report) => {
// Make or update progressbar
})
}).then((results) => { // has same keys as itemscancel
}).catch((e) => { // this happens when an error is thrown, or when is called`
e.name // "cancel"
e.message // description of error, ex. "Reason for canceling"
e.results // results processed thus far
})
`js``
mapper.reportProgress(0.25) // report current item progress
mapper.reject("Reason for rejection") // optional string describing why the queue was canceled
mapper.total // total number of items
mapper.remaining // number of items yet to be processed
mapper.progress // remaining divided by total