Skip to content

Commit

Permalink
export named function instead of default
Browse files Browse the repository at this point in the history
  • Loading branch information
shaharmor committed Jul 28, 2019
1 parent 2951c12 commit 309d46e
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 7 deletions.
22 changes: 21 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,22 @@
# webrtc-private-ip
Get your private-ip using WebRTC

> Get your private-ip using WebRTC
## Install

```
$ npm install webrtc-private-ip
```

## Usage

```js
import { webrtcPrivateIp } from 'webrtc-private-ip';

(async () => {
const ip = await webrtcPrivateIp();
if (ip) {
//=> '192.168.1.1'
}
})()
```
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
"description": "Get your private-ip using WebRTC",
"main": "dist/webrtc-private-ip.js",
"types": "dist/webrtc-private-ip.d.ts",
"files": [
"dist/**/*"
],
"scripts": {
"build": "tsc",
"lint": "npm run lint:tsc && npm run lint:eslint",
Expand All @@ -17,6 +20,10 @@
"test": "karma start",
"test:watch": "npm run test -- '--no-single-run'"
},
"keywords": [
"webrtc",
"private-ip"
],
"repository": {
"type": "git",
"url": "git+https://github.com/shaharmor/webrtc-private-ip.git"
Expand All @@ -30,7 +37,7 @@
"devDependencies": {
"@shaharmor/eslint-config": "1.0.5",
"@shaharmor/prettier-config": "1.0.1",
"@shaharmor/tsconfig": "0.0.2",
"@shaharmor/tsconfig": "0.0.3",
"@types/chai": "4.1.7",
"@types/mocha": "5.2.7",
"@types/webrtc": "0.0.25",
Expand Down
4 changes: 2 additions & 2 deletions src/webrtc-private-ip.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const IPV4_REGEX = /\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/g;

export const webrtcPrivateIp = async (): Promise<string | undefined> => {
export async function webrtcPrivateIp(): Promise<string | undefined> {
return new Promise(async (resolve) => {
const peer = new window.RTCPeerConnection();
const datachannel = peer.createDataChannel('channel');
Expand Down Expand Up @@ -31,4 +31,4 @@ export const webrtcPrivateIp = async (): Promise<string | undefined> => {
const sdp = await peer.createOffer();
await peer.setLocalDescription(sdp);
});
};
}
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"compilerOptions": {
"declaration": true,
"outDir": "dist",
"target": "es6",
"lib": ["es6", "dom"],
"types": ["webrtc", "mocha"]
},
Expand Down

0 comments on commit 309d46e

Please sign in to comment.