Comparing version 0.0.12 to 0.0.13
0.0.13 / 2013-07-31 | ||
================== | ||
* move getIP() to address, fixed #2 | ||
0.0.12 / 2013-06-27 | ||
@@ -3,0 +8,0 @@ ================== |
@@ -1,1 +0,1 @@ | ||
module.exports = process.env.UTILITY_COV ? require('./lib-cov/utility') : require('./lib/utility'); | ||
module.exports = require('./lib/utility'); |
@@ -13,4 +13,4 @@ /*! | ||
var os = require('os'); | ||
var crypto = require('crypto'); | ||
var address = require('address'); | ||
@@ -261,26 +261,4 @@ /** | ||
function _getIP(family, interfaceName) { | ||
var interfaces = os.networkInterfaces(); | ||
if (!interfaceName) { | ||
if (os.platform() === 'linux') { | ||
interfaceName = 'eth'; | ||
} else { | ||
interfaceName = 'en'; | ||
} | ||
} | ||
var _showWarnning = false; | ||
for (var i = 0; i < 8; i++) { | ||
var items = interfaces[interfaceName + i]; | ||
var found = false; | ||
if (items && items.length > 0) { | ||
for (var j = 0; j < items.length; j++) { | ||
var item = items[j]; | ||
if (item.family === family && !item.internal) { | ||
return item.address; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
/** | ||
@@ -293,3 +271,7 @@ * Get current machine IPv4 | ||
exports.getIP = exports.getIPv4 = function (interfaceName) { | ||
return _getIP('IPv4', interfaceName); | ||
if (!_showWarnning) { | ||
_showWarnning = true; | ||
console.warn('[WARNNING] getIP() remove, PLEASE use `https://github.com/fengmk2/address` module instead'); | ||
} | ||
return address.ip(interfaceName); | ||
}; | ||
@@ -304,3 +286,3 @@ | ||
exports.getIPv6 = function (interfaceName) { | ||
return _getIP('IPv6', interfaceName); | ||
return address.ipv6(interfaceName); | ||
}; | ||
@@ -307,0 +289,0 @@ |
{ | ||
"name": "utility", | ||
"version": "0.0.12", | ||
"version": "0.0.13", | ||
"description": "A collection of useful utilities.", | ||
@@ -12,3 +12,3 @@ "main": "index.js", | ||
"dependencies": { | ||
"address": ">=0.0.1" | ||
}, | ||
@@ -15,0 +15,0 @@ "devDependencies": { |
@@ -57,8 +57,4 @@ utility [![Build Status](https://secure.travis-ci.org/fengmk2/utility.png)](http://travis-ci.org/fengmk2/utility) [![Coverage Status](https://coveralls.io/repos/fengmk2/utility/badge.png)](https://coveralls.io/r/fengmk2/utility) | ||
// get first ip | ||
utils.getIP(); // "10.7.68.72" | ||
utils.getIPv4(); // "10.7.68.72" | ||
utils.getIP('ppp'); // "10.2.0.231" | ||
[WARNNING] getIP() remove, PLEASE use `https://github.com/fengmk2/address` module instead | ||
utils.getIPv6(); // "fe80::cabc:c8ff:feef:f996" | ||
// get a function parameter's names | ||
@@ -65,0 +61,0 @@ utils.getParamNames(function (key1, key2) {}); // ['key1', 'key2'] |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
0
20250
1
439
143
+ Addedaddress@>=0.0.1
+ Addedaddress@2.0.3(transitive)