Skip to content

Instantly share code, notes, and snippets.

@ridhwaans
Last active July 25, 2021 14:50
Show Gist options
  • Save ridhwaans/26c3acffcf05739333f2183dd6aade08 to your computer and use it in GitHub Desktop.
Save ridhwaans/26c3acffcf05739333f2183dd6aade08 to your computer and use it in GitHub Desktop.
file list to array
// get line separated list without whitespace, newline, carriage return characters
const fs = require('fs');
const path = require('path');
const DIR_PATH = path.resolve(__dirname,'../subdirectory')
const list = fs.readFileSync(`${DIR_PATH}/list_to_read.txt`, "utf-8").split("\n").map(i => i.replace(/(\r\n|\n|\r)/gm, ""))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment