Skip to content

Commit

Permalink
prioritize browser detection, remove os dependency (#65)
Browse files Browse the repository at this point in the history
  • Loading branch information
Damon Oehlman committed Jun 25, 2018
1 parent c096577 commit 0d871e1
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
function detect() {
var nodeVersion = getNodeVersion();
if (nodeVersion) {
return nodeVersion;
} else if (typeof navigator !== 'undefined') {
if (typeof navigator !== 'undefined') {
return parseUserAgent(navigator.userAgent);
}

return null;
return getNodeVersion();
}

function detectOS(userAgentString) {
Expand All @@ -19,12 +16,12 @@ function detectOS(userAgentString) {
}

function getNodeVersion() {
var isNode = typeof navigator === 'undefined' && typeof process !== 'undefined';
return isNode ? {
var isNode = typeof process !== 'undefined' && process.version;
return isNode && {
name: 'node',
version: process.version.slice(1),
os: require('os').type().toLowerCase()
} : null;
os: process.platform
};
}

function parseUserAgent(userAgentString) {
Expand Down

0 comments on commit 0d871e1

Please sign in to comment.