export function setPrototypeOf ( obj , proto ) { if ( ( Object as any ) . setPrototypeOf ) { return ( Object as any ) . setPrototypeOf ( obj , proto ) ; } ( obj as any ) . __proto__ = proto ; return obj ; } export function BKDRHash ( str ) { let hash = 0 ; const seed = 131 ; const INT_MAX = 0x7FFFFFFF ; for ( let i = 0 ; i < str . length ; i ++ ) { hash = ( hash * seed + str . charCodeAt ( i ) ) & INT_MAX ; } return hash ; } export function escapeHTML ( unsafe ) { let tags = { '&' : '&amp;' , '<' : '&lt;' , '>' : '&gt;' , '"' : '&quot;' , '\'' : '&#039;' } ; return unsafe . replace ( /[&<>"']/g , ( char ) : string => { return tags [ char ] || char ; } ) ; } export function isFireFox ( ) { return /firefox|Firefox/ . test ( navigator . userAgent ) ; } export function isChrome ( ) { return /chrome|Chrome/ . test ( navigator . userAgent ) ; } export function isSafari ( ) { return /safari|Safari/ . test ( navigator . userAgent ) && ! isChrome ( ) ; } export function isEdge ( ) { return /Edge|edge/ . test ( navigator . userAgent ) ; } export function isMSIE ( ) { return /msie|MSIE/ . test ( navigator . userAgent ) || /Trident/ . test ( navigator . userAgent ) ; }