common.ts 397 B

123456789101112131415161718
  1. import * as fs from "fs";
  2. import * as readline from "readline";
  3. export async function LoadInput(dayNumber: number): Promise<string[]> {
  4. const contents = [];
  5. const stream = fs.createReadStream(`./inputs/${dayNumber}.txt`, "utf8");
  6. const rl = readline.createInterface({
  7. input: stream,
  8. crlfDelay: Infinity,
  9. });
  10. for await (const line of rl) {
  11. contents.push(line);
  12. }
  13. return contents;
  14. }