@net-protocol/storage 0.1.7 → 0.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -411,9 +411,10 @@ declare function getChunkCount(data: string): number;
411
411
  * Assemble chunks into a single string and decompress
412
412
  * Pure function - can be used in both client and server code
413
413
  * @param chunks - Array of hex-encoded chunk strings
414
- * @returns Decompressed string or undefined if decompression fails
414
+ * @param returnHex - If true, returns hex string instead of converting to UTF-8
415
+ * @returns Decompressed string (or hex string if returnHex=true) or undefined if decompression fails
415
416
  */
416
- declare function assembleChunks(chunks: string[]): string | undefined;
417
+ declare function assembleChunks(chunks: string[], returnHex?: boolean): string | undefined;
417
418
 
418
419
  /**
419
420
  * XML reference type for chunk metadata
package/dist/index.d.ts CHANGED
@@ -411,9 +411,10 @@ declare function getChunkCount(data: string): number;
411
411
  * Assemble chunks into a single string and decompress
412
412
  * Pure function - can be used in both client and server code
413
413
  * @param chunks - Array of hex-encoded chunk strings
414
- * @returns Decompressed string or undefined if decompression fails
414
+ * @param returnHex - If true, returns hex string instead of converting to UTF-8
415
+ * @returns Decompressed string (or hex string if returnHex=true) or undefined if decompression fails
415
416
  */
416
- declare function assembleChunks(chunks: string[]): string | undefined;
417
+ declare function assembleChunks(chunks: string[], returnHex?: boolean): string | undefined;
417
418
 
418
419
  /**
419
420
  * XML reference type for chunk metadata
package/dist/index.js CHANGED
@@ -662,7 +662,7 @@ function getChunkCount(data) {
662
662
  const hexWithoutPrefix = dataBytes.slice(2);
663
663
  return Math.max(1, Math.ceil(hexWithoutPrefix.length / (CHUNK_SIZE * 2)));
664
664
  }
665
- function assembleChunks(chunks) {
665
+ function assembleChunks(chunks, returnHex) {
666
666
  try {
667
667
  let assembled = chunks[0] || "0x";
668
668
  for (let i = 1; i < chunks.length; i++) {
@@ -675,6 +675,9 @@ function assembleChunks(chunks) {
675
675
  try {
676
676
  const decompressed = pako__default.default.ungzip(bytes);
677
677
  const hexString = Buffer.from(decompressed).toString("utf8");
678
+ if (returnHex) {
679
+ return hexString.startsWith("0x") ? hexString : `0x${hexString}`;
680
+ }
678
681
  const result = viem.hexToString(hexString);
679
682
  return result;
680
683
  } catch (error) {