import type {HostInstance} from './types';
export const getCurrentTime: () => number =
typeof performance === 'object' && typeof performance.now === 'function'
? () => performance.now()
: () => Date.now();
export function getPublicInstance(instance: HostInstance): HostInstance {
if (typeof instance === 'object' && instance !== null) {
if (typeof instance.canonical === 'object' && instance.canonical !== null) {
if (
typeof instance.canonical.publicInstance === 'object' &&
instance.canonical.publicInstance !== null
) {
return instance.canonical.publicInstance;
}
}
if (typeof instance._nativeTag === 'number') {
return instance._nativeTag;
}
}
return instance;
}
export function getNativeTag(instance: HostInstance): number | null {
if (typeof instance !== 'object' || instance === null) {
return null;
}
if (
instance.canonical != null &&
typeof instance.canonical.nativeTag === 'number'
) {
return instance.canonical.nativeTag;
}
if (typeof instance._nativeTag === 'number') {
return instance._nativeTag;
}
return null;
}