Read text file to array of lines. Easy, sync, utf8 only, no configs required.
Because fs
is too low-level for such kind of tasks.
npm i readar
const readar = require('readar');
readar('path/to/some/file'); // ['line1', 'line2', 'line3']
readar('path/to/some/dir'); // Error EISDIR: illegal operation on a directory, read
readar('path/to/nonExistent/file'); // Error ENOENT: no such file or directory, open \'path/to/nonExistent/file\'
MIT