lib/tlv.js
function getLengthOfLength(lenValue, indefiniteLength) {
  var lenOfLen;
  
  if (indefiniteLength) {
    lenOfLen = 3;
  } else if (lenValue > 0x00FFFFFF) {
    lenOfLen = 5;
  } else if (lenValue > 0x0000FFFF) {
    lenOfLen = 4;
  } else if (lenValue > 0x000000FF) {
    lenOfLen = 3;
  } else if (lenValue > 0x0000007F) {
    lenOfLen = 2; 
  } else {
    lenOfLen = 1;
  }
  
  return lenOfLen
}
function getLengthOfLength(lenValue, indefiniteLength) {
  var lenOfLen;
  
  if (indefiniteLength) {
    lenOfLen = 3;
  } else if (lenValue > 0x00FFFFFF) {
    lenOfLen = 5;
  } else if (lenValue > 0x0000FFFF) {
    lenOfLen = 4;
  } else if (lenValue > 0x000000FF) {
    lenOfLen = 3;
  } else if (lenValue > 0x0000007F) {
    lenOfLen = 2; 
  } else {
    lenOfLen = 1;
  }
  
  return lenOfLen
}
function getLengthOfLength ( lenValue , indefiniteLength ) { var lenOfLen ; if ( indefiniteLength ) { lenOfLen = 3 ; } else if ( lenValue > 0x00FFFFFF ) { lenOfLen = 5 ; } else if ( lenValue > 0x0000FFFF ) { lenOfLen = 4 ; } else if ( lenValue > 0x000000FF ) { lenOfLen = 3 ; } else if ( lenValue > 0x0000007F ) { lenOfLen = 2 ; } else { lenOfLen = 1 ; } return lenOfLen }
Returns the number of bytes needed to encode the given length.
If the length is indefinite, this value takes in account the bytes needed to encode the EOC tag.

@param {number} lenValue
@param {boolean} indefiniteLength
@return {number}
Returns the number of bytes needed to encode the given length . If the length is indefinite this value takes in account the bytes needed to encode the EOC tag .