generateUUID,
handleUncaughtException,
handleUnhandledRejection,
+ isAsyncFunction,
isNotEmptyArray,
logPrefix,
logger
}
private readonly workerEventPerformanceStatistics = (data: Statistics): void => {
- this.storage?.storePerformanceStatistics(data) as undefined
+ // eslint-disable-next-line @typescript-eslint/unbound-method
+ if (isAsyncFunction(this.storage?.storePerformanceStatistics)) {
+ (
+ this.storage.storePerformanceStatistics as (
+ performanceStatistics: Statistics
+ ) => Promise<void>
+ )(data).catch(Constants.EMPTY_FUNCTION)
+ } else {
+ (this.storage?.storePerformanceStatistics as (performanceStatistics: Statistics) => void)(
+ data
+ )
+ }
}
private initializeCounters (): void {
return deepClone(object as CloneableData) as T
}
+/**
+ * Detects whether the given value is an asynchronous function or not.
+ *
+ * @param fn - Unknown value.
+ * @returns `true` if `fn` was an asynchronous function, otherwise `false`.
+ * @internal
+ */
+export const isAsyncFunction = (fn: unknown): fn is (...args: unknown[]) => Promise<unknown> => {
+ return typeof fn === 'function' && fn.constructor.name === 'AsyncFunction'
+}
+
export const isObject = (value: unknown): value is object => {
return value != null && typeof value === 'object' && !Array.isArray(value)
}
buildStoppedMessage
} from './MessageChannelUtils.js'
export {
+ isAsyncFunction,
JSONStringifyWithMapSupport,
clone,
convertToBoolean,