import { readFile } from 'node:fs/promises'; import { once } from 'node:events'; const count = Number(process.argv[2] ?? 10000); if (!Number.isSafeInteger(count) || count < 1 || count > 1000000) { throw new Error('Use an account count between 1 and 1000000'); } const { accounts } = JSON.parse(await readFile(new URL('./commerce.json', import.meta.url), 'utf8')); for (let i = 0; i < count; i++) { const account = structuredClone(accounts[i % accounts.length]); account.id = `account-${i}`; for (const order of account.orders) order.id = `${account.id}-${order.id}`; if (!process.stdout.write(JSON.stringify(account) + '\n')) { await once(process.stdout, 'drain'); } }