queueRunner.d.ts 954 B

1234567891011121314151617181920212223242526272829
  1. /**
  2. * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
  3. *
  4. * This source code is licensed under the MIT license found in the
  5. * LICENSE file in the root directory of this source tree.
  6. */
  7. export declare type Options = {
  8. clearTimeout: typeof globalThis['clearTimeout'];
  9. fail: (error: Error) => void;
  10. onException: (error: Error) => void;
  11. queueableFns: Array<QueueableFn>;
  12. setTimeout: typeof globalThis['setTimeout'];
  13. userContext: unknown;
  14. };
  15. export interface DoneFn {
  16. (error?: any): void;
  17. fail: (error: Error) => void;
  18. }
  19. export declare type QueueableFn = {
  20. fn: (done: DoneFn) => void;
  21. timeout?: () => number;
  22. initError?: Error;
  23. };
  24. declare type PromiseCallback = (() => void | PromiseLike<void>) | undefined | null;
  25. export default function queueRunner(options: Options): PromiseLike<void> & {
  26. cancel: () => void;
  27. catch: (onRejected?: PromiseCallback) => Promise<void>;
  28. };
  29. export {};