The Node.js® Website
at main 747 B view raw
1/// <reference types="user-agent-data-types" /> 2 3export const getArchitecture = async () => { 4 // This is necessary to detect Windows 11 on Edge. 5 // [MDN](https://developer.mozilla.org/en-US/docs/Web/API/NavigatorUAData/getHighEntropyValues) 6 // [MSFT](https://learn.microsoft.com/en-us/microsoft-edge/web-platform/how-to-detect-win11) 7 if (typeof navigator?.userAgentData?.getHighEntropyValues === 'function') { 8 const entropyValues = navigator.userAgentData.getHighEntropyValues([ 9 'architecture', 10 ]); 11 12 // Apparently in some cases this is not a Promise, we can Promisify it. 13 return Promise.resolve(entropyValues) 14 .then(({ architecture }) => architecture) 15 .catch(() => undefined); 16 } 17 18 return undefined; 19};