build/authorify.js
function(b) {
  var b2 = b.getByte();
  if(b2 === 0x80) {
    return undefined;
  }

  // see if the length is "short form" or "long form" (bit 8 set)
  var length;
  var longForm = b2 & 0x80;
  if(!longForm) {
    // length is just the first byte
    length = b2;
  } else {
    // the number of bytes the length is specified in bits 7 through 1
    // and each length byte is in big-endian base-256
    length = b.getInt((b2 & 0x7F) << 3);
  }
  return length;
}
function(b) {
  var b2 = b.getByte();
  if(b2 === 0x80) {
    return undefined;
  }

  // see if the length is "short form" or "long form" (bit 8 set)
  var length;
  var longForm = b2 & 0x80;
  if(!longForm) {
    // length is just the first byte
    length = b2;
  } else {
    // the number of bytes the length is specified in bits 7 through 1
    // and each length byte is in big-endian base-256
    length = b.getInt((b2 & 0x7F) << 3);
  }
  return length;
}
function ( b ) { var b2 = b . getByte ( ) ; if ( b2 === 0x80 ) { return undefined ; } // see if the length is "short form" or "long form" (bit 8 set) var length ; var longForm = b2 & 0x80 ; if ( ! longForm ) { // length is just the first byte length = b2 ; } else { // the number of bytes the length is specified in bits 7 through 1 // and each length byte is in big-endian base-256 length = b . getInt ( ( b2 & 0x7F ) << 3 ) ; } return length ; }
Gets the length of an ASN.1 value.

In case the length is not specified, undefined is returned.

@param b the ASN.1 byte buffer.

@return the length of the ASN.1 value.
Gets the length of an ASN . 1 value .