use Array.includes

This commit is contained in:
David Sanders
2020-11-11 09:43:17 -08:00
committed by GitHub
parent 5f4b719444
commit af2f744186
+2 -11
View File
@@ -23,17 +23,8 @@ export const isSafari = /^((?!chrome|android).)*safari/i.test(userAgent);
// Find the users platform. We use this to interpret the meta key
// and ISO third level shifts.
// http://stackoverflow.com/q/19877924/577598
export const isMac = contains(['Macintosh', 'MacIntel', 'MacPPC', 'Mac68K'], platform);
export const isMac = ['Macintosh', 'MacIntel', 'MacPPC', 'Mac68K'].includes(platform);
export const isIpad = platform === 'iPad';
export const isIphone = platform === 'iPhone';
export const isWindows = contains(['Windows', 'Win16', 'Win32', 'WinCE'], platform);
export const isWindows = ['Windows', 'Win16', 'Win32', 'WinCE'].includes(platform);
export const isLinux = platform.indexOf('Linux') >= 0;
/**
* Return if the given array contains the given element
* @param arr The array to search for the given element.
* @param el The element to look for into the array
*/
function contains(arr: any[], el: any): boolean {
return arr.indexOf(el) >= 0;
}