queueRunner.d.ts 969 B

123456789101112131415161718192021222324252627282930
  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. declare type Global = NodeJS.Global;
  8. export declare type Options = {
  9. clearTimeout: Global['clearTimeout'];
  10. fail: (error: Error) => void;
  11. onException: (error: Error) => void;
  12. queueableFns: Array<QueueableFn>;
  13. setTimeout: Global['setTimeout'];
  14. userContext: unknown;
  15. };
  16. export interface DoneFn {
  17. (error?: any): void;
  18. fail: (error: Error) => void;
  19. }
  20. export declare type QueueableFn = {
  21. fn: (done: DoneFn) => void;
  22. timeout?: () => number;
  23. initError?: Error;
  24. };
  25. declare type PromiseCallback = (() => void | PromiseLike<void>) | undefined | null;
  26. export default function queueRunner(options: Options): PromiseLike<void> & {
  27. cancel: () => void;
  28. catch: (onRejected?: PromiseCallback) => Promise<void>;
  29. };
  30. export {};