lib/tlv.js
function parseTag(buf) {
  var index = 0;
  var tag = buf[index++];
  var constructed = (tag & 0x20) == 0x20;
  
  if ((tag & 0x1F) == 0x1F) {
    do {
      tag = tag << 8;
      tag = tag | buf[index++];  
    } while((tag & 0x80) == 0x80);
    
    if (index > 4) {
      throw new RangeError("The length of the tag cannot be more than 4 bytes in this implementation");
    }
  }
  return { tag: tag, length: index, constructed: constructed };
}
function parseTag(buf) {
  var index = 0;
  var tag = buf[index++];
  var constructed = (tag & 0x20) == 0x20;
  
  if ((tag & 0x1F) == 0x1F) {
    do {
      tag = tag << 8;
      tag = tag | buf[index++];  
    } while((tag & 0x80) == 0x80);
    
    if (index > 4) {
      throw new RangeError("The length of the tag cannot be more than 4 bytes in this implementation");
    }
  }
  return { tag: tag, length: index, constructed: constructed };
}
function parseTag ( buf ) { var index = 0 ; var tag = buf [ index ++ ] ; var constructed = ( tag & 0x20 ) == 0x20 ; if ( ( tag & 0x1F ) == 0x1F ) { do { tag = tag << 8 ; tag = tag | buf [ index ++ ] ; } while ( ( tag & 0x80 ) == 0x80 ) ; if ( index > 4 ) { throw new RangeError ( "The length of the tag cannot be more than 4 bytes in this implementation" ) ; } } return { tag : tag , length : index , constructed : constructed } ; }
Parses the first bytes of the given Buffer as a TLV tag. The tag is returned as an object
containing the tag, its length in bytes and whether it is constructed or not.

@param {Buffer} buf
@return {object}
Parses the first bytes of the given Buffer as a TLV tag . The tag is returned as an object containing the tag its length in bytes and whether it is constructed or not .