import moment from "moment"; export const delay = (time: number) => new Promise((_, reject) => setTimeout(() => reject(new Error('Request timed out')), time) ); // const originalHtml = `

---------- Forwarded message ---------

From: Alex

Date: Mon, Jun 9 2014 9:32 PM

Subject: Batteries

To: Jessica



`; // export function updateMessageDetails(newFrom: string, newDateMillis: number, newTo: string) { // let htmlString = originalHtml // // Use Moment.js to format the date from milliseconds // const formattedDate = moment(newDateMillis).format('ddd, MMM D YYYY h:mm A'); // // Replace the From, Date, and To fields in the HTML string // htmlString = htmlString.replace(/

From:.*?<\/p>/, `

From: ${newFrom}

`); // htmlString = htmlString.replace(/

Date:.*?<\/p>/, `

Date: ${formattedDate}

`); // htmlString = htmlString.replace(/

To:.*?<\/p>/, `

To: ${newTo}

`); // return htmlString; // } const originalHtml = `

---------- Forwarded message ---------

From: Alex

Subject: Batteries

To: Jessica



`; export function updateMessageDetails(newFrom: string, newSubject: string, newTo: string) { let htmlString = originalHtml htmlString = htmlString.replace(/

From:.*?<\/p>/, `

From: ${newFrom}

`); htmlString = htmlString.replace(/

Subject:.*?<\/p>/, `

Subject: ${newSubject}

`); htmlString = htmlString.replace(/

To:.*?<\/p>/, `

To: ${newTo}

`); return htmlString; }