index.js.flow 1010 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. // @flow
  2. declare type FilePath = string;
  3. declare type GlobPattern = string;
  4. export type BackendType =
  5. | 'fs-events'
  6. | 'watchman'
  7. | 'inotify'
  8. | 'windows'
  9. | 'brute-force';
  10. export type EventType = 'create' | 'update' | 'delete';
  11. export interface Options {
  12. ignore?: Array<FilePath | GlobPattern | RegExp>;
  13. backend?: BackendType;
  14. }
  15. export type SubscribeCallback = (err: ?Error, events: Array<Event>) => mixed;
  16. export interface AsyncSubscription {
  17. unsubscribe(): Promise<void>;
  18. }
  19. export interface Event {
  20. path: FilePath;
  21. type: EventType;
  22. }
  23. declare module.exports: {
  24. getEventsSince(
  25. dir: FilePath,
  26. snapshot: FilePath,
  27. opts?: Options,
  28. ): Promise<Array<Event>>,
  29. subscribe(
  30. dir: FilePath,
  31. fn: SubscribeCallback,
  32. opts?: Options,
  33. ): Promise<AsyncSubscription>,
  34. unsubscribe(
  35. dir: FilePath,
  36. fn: SubscribeCallback,
  37. opts?: Options,
  38. ): Promise<void>,
  39. writeSnapshot(
  40. dir: FilePath,
  41. snapshot: FilePath,
  42. opts?: Options,
  43. ): Promise<FilePath>,
  44. };