Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

dev-ip

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dev-ip - npm Package Compare versions

Comparing version 0.1.7 to 1.0.0

5

example.js
var devip = require("./lib/dev-ip");
var ip = devip.getIp(null);
console.log(ip);
var ipCli = devip.getIp("cli");
var ip = devip();
console.log(ip);

41

lib/dev-ip.js

@@ -12,5 +12,2 @@ #! /usr/bin/env node

var os = require("os");
var _ = require("lodash");
var messages = {

@@ -20,12 +17,12 @@ error: "Couldn't find a suitable IP for you to use. (You're probably offline!)"

exports.getIp = function (env) {
/**
* @returns {Array}
*/
function getIp() {
var networkInterfaces = os.networkInterfaces();
var networkInterfaces = require("os").networkInterfaces();
var matches = [];
var returnValue;
// loop through results and check that it's an IPv4 address & it's not internal
_.each(networkInterfaces, function (_interface) {
_.each(_interface, function (address) {
Object.keys(networkInterfaces).forEach(function (item) {
networkInterfaces[item].forEach(function (address) {
if (address.internal === false && address.family === "IPv4") {

@@ -37,22 +34,14 @@ matches.push(address.address);

if (matches.length) {
return matches;
};
if (matches.length === 1) {
returnValue = matches[0];
} else {
returnValue = matches;
}
module.exports = getIp;
return returnValue;
}
if (require.main === module) {
if (env === "cli") {
return messages.error;
var out = getIp();
if (!out.length) {
return console.log(messages.error);
}
return false;
};
if (require.main === module) {
console.log(exports.getIp("cli"));
console.log(getIp("cli"));
}
{
"name": "dev-ip",
"description": "Find a suitable IP host to view local websites on.",
"version": "0.1.7",
"homepage": "https://github.com/shakyshane/dev-ip",
"author": {
"name": "Shane Osbourne",
"email": "shane.osbourne8@gmail.com"
},
"repository": {
"type": "git",
"url": "git://github.com/shakyshane/dev-ip.git"
},
"bugs": {
"url": "https://github.com/shakyshane/dev-ip/issues"
},
"licenses": [
{
"type": "MIT",
"url": "https://github.com/shakyshane/dev-ip/blob/master/LICENSE-MIT"
}
],
"main": "lib/dev-ip",
"engines": {
"node": ">= 0.8.0"
},
"scripts": {
"test": "gulp"
},
"dependencies": {
"lodash": "~2.2.1"
},
"devDependencies": {
"gulp": "~3.4.0",
"gulp-mocha": "~0.4.1",
"gulp-jshint": "~1.4.0",
"chai": "~1.9.0",
"sinon": "~1.8.2"
},
"keywords": [],
"bin": {
"dev-ip": "lib/dev-ip.js"
"name": "dev-ip",
"description": "Find a suitable IP host to view local websites on.",
"version": "1.0.0",
"homepage": "https://github.com/shakyshane/dev-ip",
"author": {
"name": "Shane Osbourne",
"email": "shane.osbourne8@gmail.com"
},
"repository": {
"type": "git",
"url": "git://github.com/shakyshane/dev-ip.git"
},
"bugs": {
"url": "https://github.com/shakyshane/dev-ip/issues"
},
"licenses": [
{
"type": "MIT",
"url": "https://github.com/shakyshane/dev-ip/blob/master/LICENSE-MIT"
}
],
"main": "lib/dev-ip",
"engines": {
"node": ">= 0.8.0"
},
"scripts": {
"lint": "jshint lib/*.js test/*.js",
"unit": "mocha",
"test": "npm run lint && npm run unit"
},
"devDependencies": {
"chai": "^1.10.0",
"mocha": "^2.1.0",
"sinon": "^1.12.2"
},
"keywords": [],
"bin": {
"dev-ip": "lib/dev-ip.js"
},
"dependencies": {
"jshint": "^2.5.11"
}
}

@@ -20,4 +20,4 @@ # dev-ip [![Build Status](https://travis-ci.org/shakyShane/dev-ip.png?branch=master)](https://travis-ci.org/shakyShane/dev-ip)

```javascript
var dev_ip = require('dev-ip');
dev_ip.getIp(); // "192.168.1.76" or false if nothing found (ie, offline user)
var devip = require('dev-ip');
devip(); // "192.168.1.76" or false if nothing found (ie, offline user)
```

@@ -24,0 +24,0 @@

@@ -24,3 +24,3 @@ "use strict";

beforeEach(function () {
result = devIp.getIp(null);
result = devIp(null);
});

@@ -32,3 +32,3 @@ after(function () {

var expected = match1;
assert.equal(result, expected);
assert.deepEqual(result, [expected]);
});

@@ -48,3 +48,3 @@ it("should return a string matching the regex", function () {

beforeEach(function () {
result = devIp.getIp(null);
result = devIp(null);
});

@@ -75,11 +75,7 @@ after(function () {

});
it("should return false", function () {
var actual = devIp.getIp(null);
assert.isFalse(actual);
it("should return empty array", function () {
var actual = devIp();
assert.isArray(actual);
assert.equal(actual.length, 0);
});
it("should return an error message if used on command line", function () {
var actual = devIp.getIp("cli");
var expected = "Couldn't find a suitable IP for you to use. (You're probably offline!)";
assert.equal(actual, expected);
});
});

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc