Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
exports.validate = function (file, callback) {
var titleIDs = {}; // List of title IDs
var titleIdColumn = false;
var syntaxError = false;
var currentLine = 1;
var nbErrors = 0;
var nbWarnings = 0;
var fileStream = fs.createReadStream(file);
var emitter = new EventEmitter();
var detector = new jschardet.UniversalDetector();
var data;
detector.reset();
// Store errors if a callback is provided
if (typeof callback === 'function') {
var pkbErrors = [];
var pkbWarnings = [];
emitter
.on('error', function (error) { callback(error); })
.on('syntaxError', function (error) { callback(error); })
.on('pkbError', function (msg, line) { pkbErrors.push({ message: msg, line: line }); })
.on('pkbWarning', function (msg, line) { pkbWarnings.push({ message: msg, line: line }); })
.on('end', function () { callback(null, pkbErrors, pkbWarnings); });
}