PCancelable.d.ts 939 B

1234567891011121314151617
  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 default class PCancelable<T> extends Promise<T> {
  8. private _pending;
  9. private _canceled;
  10. private _promise;
  11. private _cancel?;
  12. private _reject;
  13. constructor(executor: (onCancel: (cancelHandler: () => void) => void, resolve: (value?: T | PromiseLike<T>) => void, reject: (reason?: unknown) => void) => void);
  14. then<TResult1 = T, TResult2 = never>(onFulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | undefined | null, onRejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | undefined | null): Promise<TResult1 | TResult2>;
  15. catch<TResult>(onRejected?: ((reason: unknown) => TResult | PromiseLike<TResult>) | undefined | null): Promise<T | TResult>;
  16. cancel(): void;
  17. }