returns export function isNodeEnv ( ) { return typeof process === 'object' && process ?. versions ?. node !== undefined ; } returns export function isBrowserEnv ( ) { return typeof window === 'object' && window ?. document !== undefined ; } const fallbackGlobalObject = { } ; returns export const getGlobalObject = ( ) : any => { if ( isNodeEnv ( ) ) { return global ; } else if ( typeof window !== 'undefined' ) { return window ; } else if ( typeof self !== 'undefined' ) { return self ; } else { return fallbackGlobalObject ; } } ; export const getGlobalAmplitudeNamespace = ( ) : any => { const global = getGlobalObject ( ) ; if ( global . __AMPLITUDE__ === undefined ) { global . __AMPLITUDE__ = { } ; } return global . __AMPLITUDE__ ; } ; param milliseconds export const asyncSleep = async ( milliseconds ) : Promise < void > => { return await new Promise ( resolve => setTimeout ( resolve , milliseconds ) ) ; } ; returns export const prototypeJsFix = ( ) : boolean => { interface Window { Prototype ? : Record < string , any > ; } interface ArrayConstructor { prototype ? : { toJSON ? : Function ; } ; } if ( isBrowserEnv ( ) ) { const augmentedWindow = window as Window ; const augmentedArray = Array as ArrayConstructor ; if ( augmentedWindow . Prototype !== undefined && augmentedArray . prototype ?. toJSON !== undefined ) { delete augmentedArray . prototype . toJSON ; return true ; } } return false ; } ;