/** * Function to clean up unwanted characters from the output data. * @param {string} data - The raw data to be cleaned. * @returns {string} - The cleaned data. */ export const cleanData = (data) => { return data .replace(/--More--\s*BS\s*BS\s*BS\s*BS\s*BS\s*BS/g, '') .replace(/\s*--More--\s*/g, '') .replace(/\x1b\[[0-9;]*m/g, '') // Remove ANSI escape codes .replace(/\x08/g, '') .replace(/[^\x20-\x7E\r\n]/g, '') // Remove non-printable characters // .replace(/\r\n/g, '\n') }