function DecodeVersionHash(versionHash) {
    if (!versionHash.startsWith("hq__")) {
      throw new Error("Invalid version hash: \"".concat(versionHash, "\""));
    }

    versionHash = versionHash.replace("hq__", ""); // Decode base58 payload

    var bytes = MultiHash.fromB58String(versionHash); // Remove 32 byte SHA256 digest

    var digestBytes = bytes.slice(0, 32);
    var digest = digestBytes.toString("hex");
    bytes = bytes.slice(32); // Determine size of varint content size

    var sizeLength = 0;

    while (bytes[sizeLength] >= 128) {
      sizeLength++;
    }

    sizeLength++; // Remove size

    var sizeBytes = bytes.slice(0, sizeLength);
    var size = VarInt.decode(sizeBytes);
    bytes = bytes.slice(sizeLength); // Remaining bytes is object ID

    var objectId = "iq__" + MultiHash.toB58String(bytes); // Part hash is B58 encoded version hash without the ID

    var partHash = "hqp_" + MultiHash.toB58String(Buffer.concat([digestBytes, sizeBytes]));
    return {
      digest: digest,
      size: size,
      objectId: objectId,
      partHash: partHash
    };
  }
/**
   * Decode the specified version hash into its component parts
   *
   * @param versionHash
   *
   * @returns {Object} - Components of the version hash.
   */
Decode the specified version hash into its component parts
@param versionHash

@returns {Object} - Components of the version hash.
Decode the specified version hash into its component parts @param versionHash @returns { Object } - Components of the version hash .
function DecodeVersionHash(versionHash) {
    if (!versionHash.startsWith("hq__")) {
      throw new Error("Invalid version hash: \"".concat(versionHash, "\""));
    }
    versionHash = versionHash.replace("hq__", ""); 
    var bytes = MultiHash.fromB58String(versionHash); 
    var digestBytes = bytes.slice(0, 32);
    var digest = digestBytes.toString("hex");
    bytes = bytes.slice(32); 
    var sizeLength = 0;
    while (bytes[sizeLength] >= 128) {
      sizeLength++;
    }
    sizeLength++; 
    var sizeBytes = bytes.slice(0, sizeLength);
    var size = VarInt.decode(sizeBytes);
    bytes = bytes.slice(sizeLength); 
    var objectId = "iq__" + MultiHash.toB58String(bytes); 
    var partHash = "hqp_" + MultiHash.toB58String(Buffer.concat([digestBytes, sizeBytes]));
    return {
      digest: digest,
      size: size,
      objectId: objectId,
      partHash: partHash
    };
  }
function DecodeVersionHash ( versionHash ) { if ( ! versionHash . startsWith ( "hq__" ) ) { throw new Error ( "Invalid version hash: \"" . concat ( versionHash , "\"" ) ) ; } versionHash = versionHash . replace ( "hq__" , "" ) ; var bytes = MultiHash . fromB58String ( versionHash ) ; var digestBytes = bytes . slice ( 0 , 32 ) ; var digest = digestBytes . toString ( "hex" ) ; bytes = bytes . slice ( 32 ) ; var sizeLength = 0 ; while ( bytes [ sizeLength ] >= 128 ) { sizeLength ++ ; } sizeLength ++ ; var sizeBytes = bytes . slice ( 0 , sizeLength ) ; var size = VarInt . decode ( sizeBytes ) ; bytes = bytes . slice ( sizeLength ) ; var objectId = "iq__" + MultiHash . toB58String ( bytes ) ; var partHash = "hqp_" + MultiHash . toB58String ( Buffer . concat ( [ digestBytes , sizeBytes ] ) ) ; return { digest : digest , size : size , objectId : objectId , partHash : partHash } ; }
Decode the specified version hash into its component parts
 @param versionHash
Decode the specified version hash into its component parts @param versionHash
// Decode base58 payload // Remove 32 byte SHA256 digest // Determine size of varint content size // Remove size // Remaining bytes is object ID // Part hash is B58 encoded version hash without the ID