function uniqId(prefix: string = "", moreEntropy: boolean = false): string { const timestamp: number = Date.now(); // Get the current timestamp in milliseconds let uniqueId: string = prefix + timestamp.toString(16); // Convert timestamp to hex and add prefix if (moreEntropy) { uniqueId += "." + Math.floor(Math.random() * 100000000).toString(16); } return uniqueId; } export default uniqId; // Usage: // console.log(uniqid()); // e.g., "1708334097823" // console.log(uniqid("id_")); // e.g., "id_1708334097823" // console.log(uniqid("id_", true)); // e.g., "id_1708334097823.4a7f35"