https://github.com/zwingz/lite-queue
a queue manager for sync/async function
https://github.com/zwingz/lite-queue
javascript queue
Last synced: about 2 months ago
JSON representation
a queue manager for sync/async function
- Host: GitHub
- URL: https://github.com/zwingz/lite-queue
- Owner: zWingz
- License: mit
- Created: 2019-05-17T09:46:15.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2023-01-03T22:12:02.000Z (over 3 years ago)
- Last Synced: 2025-05-18T22:14:01.735Z (about 1 year ago)
- Topics: javascript, queue
- Language: TypeScript
- Homepage:
- Size: 846 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: License
Awesome Lists containing this project
README
## lite-queue
[](https://circleci.com/gh/zWingz/lite-queue)
[](https://codecov.io/gh/zWingz/lite-queue)
call `function` in queue
### Usage
```javascript
import Queue from 'lite-queue'
const q = new Queue()
// sync function
q.exec(() => {
return 1
}).then(d => {
console.log(d === 1) // true
})
// async
q.exec(() => {
return new Promise(res => {
res(2)
})
}).then(d => {
console.log(d === 2) // true
})
```
### with done callback
```javascript
import Queue from 'lite-queue'
const q = new Queue()
const opt = { useDone: true }
q.exec(() => 1, opt)
q.exec(() => 2, opt)
q.exec(() => 3, opt)
q.done().then(values => {
console.log(values) // [1,2,3]
})
```