thai-citizenid-gen
Version:
A library for generating valid Thai Citizen IDs and mock Thai personal data. Updated to correctly follow the ID generation algorithm and resolve security vulnerabilities in dependencies.
20 lines (15 loc) • 595 B
text/typescript
import * as fs from 'fs';
import { createObjectCsvWriter } from 'csv-writer';
export function exportToJson(data: any[], filePath: string) {
fs.writeFileSync(filePath, JSON.stringify(data, null, 2), 'utf-8');
console.log(`✅ Exported JSON to ${filePath}`);
}
export async function exportToCsv(data: any[], filePath: string) {
const headers = Object.keys(data[0]).map((key) => ({ id: key, title: key }));
const csvWriter = createObjectCsvWriter({
path: filePath,
header: headers,
});
await csvWriter.writeRecords(data);
console.log(`✅ Exported CSV to ${filePath}`);
}