Simple add only async task queue with concurrency support
Built with ❤︎ by tiaanduplessis and contributors
$ npm install @tiaanduplessis/conqueue
# OR
$ yarn add @tiaanduplessis/conqueue
const Conqueue = require('conqueue')
const tasks = new Conqueue(2) // Allow 2 tasks to be done concurrently
const a = () =>
new Promise(resolve =>
setTimeout(() => {
console.log('a - done')
resolve(1)
}, 1000)
)
const b = () =>
new Promise(resolve =>
setTimeout(() => {
console.log('b - done')
resolve(2)
}, 2000)
)
const c = () => {
console.log('c - done')
return 3
}
const d = () =>
new Promise(resolve =>
setTimeout(() => {
console.log('d - done')
resolve(4)
}, 5000)
)
const e = () =>
new Promise(resolve =>
setTimeout(() => {
console.log('e - done')
resolve(5)
}, 3000)
)
const f = () => {
console.log('f - done')
return 36
}
tasks.add(a).add(b).add(c).add(d).add(e).add(f)
// or
tasks.add([a, b, c, d, e, f])
// a - done
// c - done
// b - done
// e - done
// f - done
// a - done
// d - done
// c - done
// b - done
// e - done
// f - done
// d - done
Contributions are welcome!
- Fork it.
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request :D
Or open up a issue.
Licensed under the MIT License.