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

utility

Package Overview
Dependencies
Maintainers
1
Versions
60
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

utility - npm Package Compare versions

Comparing version 0.0.12 to 0.0.13

5

History.md
0.0.13 / 2013-07-31
==================
* move getIP() to address, fixed #2
0.0.12 / 2013-06-27

@@ -3,0 +8,0 @@ ==================

2

index.js

@@ -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']

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