index.js.flow 998 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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>,
  13. backend?: BackendType
  14. }
  15. export type SubscribeCallback = (
  16. err: ?Error,
  17. events: Array<Event>
  18. ) => mixed;
  19. export interface AsyncSubscription {
  20. unsubscribe(): Promise<void>
  21. }
  22. export interface Event {
  23. path: FilePath,
  24. type: EventType
  25. }
  26. declare module.exports: {
  27. getEventsSince(
  28. dir: FilePath,
  29. snapshot: FilePath,
  30. opts?: Options
  31. ): Promise<Array<Event>>,
  32. subscribe(
  33. dir: FilePath,
  34. fn: SubscribeCallback,
  35. opts?: Options
  36. ): Promise<AsyncSubscription>,
  37. unsubscribe(
  38. dir: FilePath,
  39. fn: SubscribeCallback,
  40. opts?: Options
  41. ): Promise<void>,
  42. writeSnapshot(
  43. dir: FilePath,
  44. snapshot: FilePath,
  45. opts?: Options
  46. ): Promise<FilePath>
  47. }