TimedQueue.d.ts 540 B

12345678910111213141516171819202122
  1. /**
  2. * Queue that is flushed automatically when it reaches some item limit
  3. * or when timeout is reached.
  4. */
  5. export declare class TimedQueue<T> {
  6. /**
  7. * Queue will be flushed when it reaches this number of items.
  8. */
  9. itemLimit: number;
  10. /**
  11. * Queue will be flushed after this many milliseconds.
  12. */
  13. timeLimit: number;
  14. /**
  15. * Method that will be called when queue is flushed.
  16. */
  17. onFlush: (list: T[]) => void;
  18. private list;
  19. private timer;
  20. push(item: T): void;
  21. flush(): T[];
  22. }