import { noOp } from './function' ; internal export const CancelSymbol = Symbol ( 'cancelled-promise' ) ; /**
 * The type returned by the  cancellablePromise function.
 *
 *  internal export interface CancellablePromiseFunction < T , K = unknown > { /**
     * The resultant promise that groups the original promise, passed as the first parameter, and the
     * promise created in cancellablePromise, which rejects the resultant promise if called.
     */ promise : Promise < T > ; /**
     * Function to cancel the resultant promise. This function triggers the reject of the second
     * promise of the promise race. The first parameter is the resultant promise rejection value.
     */ cancel : ( payload ? : K ) => void ; } remarks param promise param cancelCallback returns CancellablePromiseFunction  CancellablePromiseFunction .
 *
 *  internal export function cancellablePromise < T , K = unknown > ( promise , cancelCallback ? ) { let cancel = noOp ; const cancelPromise = new Promise < never > ( ( _ , reject ) => { cancel = payload => { reject ( CancelSymbol ) ; cancelCallback ?. ( payload ) ; } ; } ) ; return { promise : Promise . race ( [ promise , cancelPromise ] ) , cancel } ; }