-
Notifications
You must be signed in to change notification settings - Fork 37
/
test.js
31 lines (26 loc) · 794 Bytes
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/* jshint node: true */
'use strict';
var macaddress = require('./index.js');
macaddress.one(function (err, mac) {
if (err || !/[a-f0-9]{2}(:[a-f0-9]{2}){5}/.test(mac)) {
console.log(mac + " does not work");
throw err || mac;
}
console.log("Mac address for this host: %s", mac);
});
macaddress.all(function (err, all) {
if (err) {
throw err;
}
console.log(JSON.stringify(all, null, 2));
});
console.log(JSON.stringify(macaddress.networkInterfaces(), null, 2));
if (typeof Promise !== 'undefined') {
macaddress.one().then(function (result) {
console.log("Mac address for this host using Promises: %s", result);
});
macaddress.all().then(function (result) {
console.log("all() using promises");
console.log(JSON.stringify(result, null, 2));
});
}