airship-server
Version:
Airship is a framework for Node.JS & TypeScript that helps you to write big, scalable and maintainable API servers.
20 lines (17 loc) • 495 B
text/typescript
export default class CallbackQueue {
private _delay: number
private _queue: Function[] = []
constructor(countPerSec: number) {
this._delay = 1000 / countPerSec
setInterval(() => {
if(this._queue.length !== 0){
const func = this._queue.shift()
if (func) //just to make ts happy
func()
}
}, this._delay)
}
public push(func: Function) {
this._queue.push(func)
}
}