Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const getObjects = function (url, file, lineToObj, cb) {
const ftp = new FTP();
ftp.on('ready', () => {
ftp.get(file, (err, stream) => {
if (err) {
return cb(err);
}
let objects = [];
const lines = byline.createStream(stream, { encoding: 'utf8' });
stream.once('close', function () {
ftp.end();
cb(null, objects);
});
lines.on('data', function (line) {
line = line.split('|');
objects.push(lineToObj(line));
});
});