Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. import { EventEmitter } from 'events';
  2.  
  3. declare enum TimerStatuses {
  4. Tick = 'tick',
  5. Done = 'done',
  6. StatusChanged = 'statusChanged',
  7. }
  8.  
  9. declare namespace tinytimerjs {
  10. class Timer extends EventEmitter {
  11. /** Create a new Timer. Interval defaults to 1000. Stopwatch defaults to false. */
  12. constructor(options: {
  13. interval?: number,
  14. stopwatch?: boolean,
  15. });
  16.  
  17. /** The time remaining. If stopped, returns 0. If paused but without the pause time, returns the current datetime. */
  18. time: number;
  19.  
  20. /** The duration of the timer. Returns 0 if stopped. */
  21. duration: number;
  22.  
  23. /** The status of the timer. */
  24. status: TimerStatuses;
  25.  
  26. /** Start the timer with the provided duration and interval. Interval defaults to interval provided in constructor. */
  27. start(duration: number, interval?: number): void;
  28.  
  29. /** Stop the timer. */
  30. stop(): void;
  31.  
  32. /** Pause the timer. */
  33. pause(): void;
  34.  
  35. /** Resume the timer. */
  36. resume(): void;
  37. }
  38. }
  39.  
  40. export = tinytimerjs;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement