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.9 to 0.0.10

6

History.md
0.0.10 / 2013-06-25
==================
* add getIP()
* add more test cases
0.0.9 / 2013-05-08

@@ -3,0 +9,0 @@ ==================

@@ -13,2 +13,3 @@ /*!

var os = require('os');
var crypto = require('crypto');

@@ -259,1 +260,38 @@

};
function _getIP(family, interfaceName) {
var interfaces = os.networkInterfaces();
interfaceName = interfaceName || 'en';
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;
}
}
}
}
}
/**
* Get current machine IPv4
*
* @param {String} [interfaceName] interface name, default is 'en'
* @return {String} IP address
*/
exports.getIP = exports.getIPv4 = function (interfaceName) {
return _getIP('IPv4', interfaceName);
};
/**
* Get current machine IPv6
*
* @param {String} [interfaceName] interface name, default is 'en'
* @return {String} IP address
*/
exports.getIPv6 = function (interfaceName) {
return _getIP('IPv6', interfaceName);
};

12

package.json
{
"name": "utility",
"version": "0.0.9",
"version": "0.0.10",
"description": "A collection of useful utilities.",
"main": "index.js",
"scripts": {
"test": "make test"
"test": "make test-all",
"blanket": { "pattern": "utility/lib" },
"travis-cov": { "threshold": 99 }
},

@@ -14,4 +16,8 @@ "dependencies": {

"should": "*",
"mm": "*",
"moment": "*",
"jscover": "*",
"blanket": "*",
"travis-cov": "*",
"coveralls": "*",
"mocha-lcov-reporter": "*",
"benchmark": "*",

@@ -18,0 +24,0 @@ "mocha": "*"

@@ -1,2 +0,2 @@

utility [![Build Status](https://secure.travis-ci.org/fengmk2/utility.png)](http://travis-ci.org/fengmk2/utility)
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)
=======

@@ -8,4 +8,2 @@

* jscoverage: [100%](http://fengmk2.github.com/coverage/utility.html)
## Install

@@ -58,2 +56,9 @@

utils.decodeURIComponent(utils.encodeURIComponent('你好, nodejs')).should.equal('你好, nodejs');
// get first ip
utils.getIP(); // "10.7.68.72"
utils.getIPv4(); // "10.7.68.72"
utils.getIP('ppp'); // "10.2.0.231"
utils.getIPv6(); // "fe80::cabc:c8ff:feef:f996"
```

@@ -60,0 +65,0 @@

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