Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
MAC address parsing functions
JavaScript
branch: master

README.md

mac-address

MAC address parsing functions.

Build Status

Example

var mac = require('mac-address');
var bufferEqual = require('buffer-equal');

var string = '11:22:33:44:55:66';
var buffer = new Buffer([0x11, 0x22, 0x33, 0x44, 0x55, 0x66]);

// basics
mac.toString(buffer) === string;            // true
bufferEqual(mac.toBuffer(string), buffer);  // true

var longBuffer = new Buffer(1024);
var offset = 512;

// write directly into an existing buffer
mac.toBuffer(string, longBuffer, offset);

// parse out of the middle of a buffer
mac.toString(longBuffer, offset);

// exceptions
mac.toString(new Buffer(mac.LENGTH - 1));   // throws illegal length Error
mac.toBuffer('zz:xx::b:blarg');             // throws illegal format Error

// some constants
mac.LENGTH === 6;                           // true
mac.BROADCAST === 'ff:ff:ff:ff:ff:ff';      // true
mac.ZERO === '00:00:00:00:00:00';           // true
Something went wrong with that request. Please try again.