test.js 480 B

123456789101112131415161718
  1. var macaddress = require('./index');
  2. var sync = macaddress.one(function (err, mac) {
  3. if (err || !/[a-f0-9]{2}(:[a-f0-9]{2}){5}/.test(mac)) {
  4. throw err || mac;
  5. }
  6. console.log("Mac address for this host: %s", mac);
  7. });
  8. console.log("Mac address obtained synchronously: %s", sync);
  9. macaddress.all(function (err, all) {
  10. if (err) {
  11. throw err;
  12. }
  13. console.log(JSON.stringify(all, null, 2));
  14. });
  15. console.log(JSON.stringify(macaddress.networkInterfaces(), null, 2));