Skip to content

Commit

Permalink
fix: name export
Browse files Browse the repository at this point in the history
BREAKING CHANGE: Before

```js
const getUserAgent = require("universal-user-agent")
```

Now

```js
const { getUserAgent } = require("universal-user-agent")
```
  • Loading branch information
gr2m committed Sep 3, 2019
1 parent ef4bd4f commit d671405
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 21 deletions.
6 changes: 0 additions & 6 deletions browser.js

This file was deleted.

15 changes: 0 additions & 15 deletions index.js

This file was deleted.

3 changes: 3 additions & 0 deletions src/browser.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function getUserAgent(): string {
return navigator.userAgent;
}
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { getUserAgent } from "./node";
15 changes: 15 additions & 0 deletions src/node.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import osName from "os-name";

export function getUserAgent(): string {
try {
return `Node.js/${process.version.substr(1)} (${osName()}; ${
process.arch
})`;
} catch (error) {
if (/wmic os get Caption/.test(error.message)) {
return "Windows <version undetectable>";
}

throw error;
}
}

0 comments on commit d671405

Please sign in to comment.