2022-09-05 08:30:47 +00:00
|
|
|
import {DEFERRED_PROMISE_DEBUG_TIMEOUT} from '../environment.js';
|
2023-02-15 23:09:31 +00:00
|
|
|
|
2023-05-31 21:36:19 +00:00
|
|
|
import {Deferred} from './Deferred.js';
|
2022-09-05 08:30:47 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates and returns a deferred promise using DEFERRED_PROMISE_DEBUG_TIMEOUT
|
|
|
|
* if it's specified or a normal deferred promise otherwise.
|
|
|
|
*
|
|
|
|
* @internal
|
|
|
|
*/
|
2023-05-26 09:42:22 +00:00
|
|
|
export function createDebuggableDeferred<T>(message: string): Deferred<T> {
|
2022-09-05 08:30:47 +00:00
|
|
|
if (DEFERRED_PROMISE_DEBUG_TIMEOUT > 0) {
|
2023-05-31 21:36:19 +00:00
|
|
|
return Deferred.create({
|
2022-09-05 08:30:47 +00:00
|
|
|
message,
|
|
|
|
timeout: DEFERRED_PROMISE_DEBUG_TIMEOUT,
|
|
|
|
});
|
|
|
|
}
|
2023-05-31 21:36:19 +00:00
|
|
|
return Deferred.create();
|
2022-09-05 08:30:47 +00:00
|
|
|
}
|