TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string or an instance of Buffer or URL. Received undefined
const fs = require('fs');
const EventEmitter = require('events').EventEmitter;
class WordsLoader extends EventEmitter {
constructor(file){
super();
fs.readFile(file, (err,data) => {
if(err){
throw err;
}
var words = data.toString().split('\n');
this.emit('data', words);
});
} //constructor
static create(file){ //static method
return new WordsLoader(file);
}
}
module.exports = WordsLoader;