Next.js website for Rocky Mountain Vending company featuring: - Product catalog with Stripe integration - Service areas and parts pages - Admin dashboard with Clerk authentication - SEO optimized pages with JSON-LD structured data Co-authored-by: Cursor <cursoragent@cursor.com>
26 lines
721 B
Text
26 lines
721 B
Text
export async function* readabletoIterable(readStream) {
|
|
let streamEnded = false;
|
|
let generationEnded = false;
|
|
const records = new Array();
|
|
readStream.on("error", (err) => {
|
|
if (!streamEnded) {
|
|
streamEnded = true;
|
|
}
|
|
if (err) {
|
|
throw err;
|
|
}
|
|
});
|
|
readStream.on("data", (data) => {
|
|
records.push(data);
|
|
});
|
|
readStream.on("end", () => {
|
|
streamEnded = true;
|
|
});
|
|
while (!generationEnded) {
|
|
const value = await new Promise((resolve) => setTimeout(() => resolve(records.shift()), 0));
|
|
if (value) {
|
|
yield value;
|
|
}
|
|
generationEnded = streamEnded && records.length === 0;
|
|
}
|
|
}
|