'use strict'; export function bufferToString(buffer: Buffer): string { let result = '[' for (let i = 0; i < buffer.length; i++) { if (i != 0) result += ', ' result += `${buffer[i]}` } result += ']' return result } export function compareBuffers(b1: Buffer, b2: Buffer): boolean { if (b1.length != b2.length) throw new Error(`Different buffer lengths: b1: ${b1.length}, b2: ${b2.length}`) for (let i = 0; i < b1.length; i++) { const v1 = b1[i]; const v2 = b2[i]; if (typeof v1 != typeof v2) throw new Error(`Different type values: ${typeof v1}, ${typeof v2} @${i} - ${bufferToString(b1)} ${bufferToString(b2)}`) if (v1 != v2) throw new Error(`Different values: ${v1}, ${v2} @${i} - ${bufferToString(b1)} ${bufferToString(b2)}`) } return true; }