Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return _.reduce(keys, function (output, key) {
// Retrieve the appropriate field data
let fieldData = path.evaluatePath(data, key);
if (_.isUndefined(fieldData)) { fieldData = options.EMPTY_FIELD_VALUE; }
// Add the CSV representation of the data at the key in the document to the output array
return output.concat(convertField(fieldData));
}, []);
}
fields.forEach((field) => {
let recordFieldValue = path.evaluatePath(record, field);
if (!_.isUndefined(options.emptyFieldValue) && utils.isEmptyField(recordFieldValue)) {
recordFieldValue = options.emptyFieldValue;
} else if (options.expandArrayObjects && Array.isArray(recordFieldValue)) {
recordFieldValue = processRecordFieldDataForExpandedArrayObject(recordFieldValue);
}
recordValues.push(recordFieldValue);
});