node-macaddress
Advanced tools
Comparing version 0.2.2 to 0.2.4
29
index.js
@@ -65,11 +65,18 @@ var os = require('os'); | ||
if (!ifaces[iface]) { | ||
callback("no interfaces found", null); | ||
return; | ||
if (typeof callback === 'function') { | ||
callback("no interfaces found", null); | ||
} | ||
return null; | ||
} | ||
if (ifaces[iface].mac) { | ||
callback(null, ifaces[iface].mac); | ||
return; | ||
if (typeof callback === 'function') { | ||
callback(null, ifaces[iface].mac); | ||
} | ||
return ifaces[iface].mac; | ||
} | ||
} | ||
_getMacAddress(iface, callback); | ||
if (typeof callback === 'function') { | ||
_getMacAddress(iface, callback); | ||
} | ||
return null; | ||
}; | ||
@@ -88,2 +95,9 @@ | ||
if (Object.keys(resolve).length == 0) { | ||
if (typeof callback === 'function') { | ||
callback(null, ifaces); | ||
} | ||
return ifaces; | ||
} | ||
async.parallel(resolve, function (err, result) { | ||
@@ -93,6 +107,9 @@ Object.keys(result).forEach(function (iface) { | ||
}); | ||
callback(null, ifaces); | ||
if (typeof callback === 'function') { | ||
callback(null, ifaces); | ||
} | ||
}); | ||
return null; | ||
}; | ||
module.exports = lib; |
{ | ||
"name": "node-macaddress", | ||
"version": "0.2.2", | ||
"version": "0.2.4", | ||
"description": "Get the MAC addresses (hardware addresses) of the hosts network interfaces.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -19,4 +19,6 @@ node-macaddress | ||
+ works on `Linux`, `Mac OS X`, `Windows`, and on most `UNIX` systems. | ||
+ `io.js` reports MAC addresses in `os.networkInterfaces()`, this library utilizes this information when available. | ||
+ also features a sane replacement for `os.networkInterfaces()` (see `API + Examples` below). | ||
+ `node ≥ 0.12` and `io.js` report MAC addresses in `os.networkInterfaces()` | ||
this library utilizes this information when available. | ||
+ also features a sane replacement for `os.networkInterfaces()` | ||
(see `API + Examples` below). | ||
@@ -23,0 +25,0 @@ Usage |
var macaddress = require('./index'); | ||
macaddress.one(function (err, mac) { | ||
var sync = macaddress.one(function (err, mac) { | ||
if (err || !/[a-f0-9]{2}(:[a-f0-9]{2}){5}/.test(mac)) { | ||
@@ -9,2 +9,3 @@ throw err || mac; | ||
}); | ||
console.log("Mac address obtained synchronously: %s", sync); | ||
@@ -11,0 +12,0 @@ macaddress.all(function (err, all) { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
9456
186
124