blob: eca04d05c9176c2e76771fd3193864eeb7958d43 [file] [log] [blame]
Leo Repp58b9f112021-11-22 11:57:47 +01001module.exports = function arch () {
2 /**
3 * User agent strings that indicate a 64-bit OS.
4 * See: http://stackoverflow.com/a/13709431/292185
5 */
6 var userAgent = navigator.userAgent
7 if ([
8 'x86_64',
9 'x86-64',
10 'Win64',
11 'x64;',
12 'amd64',
13 'AMD64',
14 'WOW64',
15 'x64_64'
16 ].some(function (str) {
17 return userAgent.indexOf(str) > -1
18 })) {
19 return 'x64'
20 }
21
22 /**
23 * Platform strings that indicate a 64-bit OS.
24 * See: http://stackoverflow.com/a/19883965/292185
25 */
26 var platform = navigator.platform
27 if (platform === 'MacIntel' || platform === 'Linux x86_64') {
28 return 'x64'
29 }
30
31 /**
32 * CPU class strings that indicate a 64-bit OS.
33 * See: http://stackoverflow.com/a/6267019/292185
34 */
35 if (navigator.cpuClass === 'x64') {
36 return 'x64'
37 }
38
39 /**
40 * If none of the above, assume the architecture is 32-bit.
41 */
42 return 'x86'
43}