test.js 519 B

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