(filename: string)
| 34 | }; |
| 35 | |
| 36 | async function parseCSVFile<T>(filename: string): Promise<T[]> { |
| 37 | const rows: T[] = []; |
| 38 | |
| 39 | await new Promise<void>((resolve, reject) => { |
| 40 | fs.createReadStream(filename) |
| 41 | .pipe(csvParser()) |
| 42 | .on("data", (data: any) => { |
| 43 | const row = {} as T; |
| 44 | for (const [key, value] of Object.entries(data)) { |
| 45 | row[key] = value; |
| 46 | } |
| 47 | rows.push(row); |
| 48 | }) |
| 49 | .on("end", () => { |
| 50 | resolve(); |
| 51 | }) |
| 52 | .on("error", (error: Error) => { |
| 53 | reject(error); |
| 54 | }); |
| 55 | }); |
| 56 | |
| 57 | return rows; |
| 58 | } |
| 59 | |
| 60 | const loadYamlFile = async (surveyId) => { |
| 61 | const contents = await readFile( |
nothing calls this directly
no outgoing calls
no test coverage detected