Files
lettersoup-online/001_documentation/Requirements/REQ0006/gen_customer/gen_customer.mjs

30 lines
901 B
JavaScript

import { faker } from '@faker-js/faker';
const getId = (id) => id.padStart(15, '0');
const row_array = Array.from({ length: 10 }, (_, i) => [
getId(String(i + 1)),
faker.person.firstName(),
'',
faker.internet.email(),
faker.phone.number(),
faker.company.name(),
{
country: faker.location.country(),
state: faker.location.state(),
city: faker.location.city(),
zipCode: faker.location.zipCode(),
line1: faker.location.streetAddress(),
line2: faker.location.secondaryAddress(),
},
Math.floor(Math.random() * (100 - 0 + 1)) + 0,
faker.location.timeZone(),
['en', 'de', 'es', 'fr', 'ja', 'ko', 'zh-CN'].sort(() => Math.random() - 0.5)[0],
faker.finance.currencyCode(),
]);
import fs from 'fs';
const filePath = 'output.json';
fs.writeFileSync(filePath, JSON.stringify(row_array, null, 2));
console.log(`Wrote ${row_array.length} records to ${filePath}`);