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 (document, key) {
// If there is a value at the key's index in the line, set the value; otherwise null
val = line[key.index] ? line[key.index] : null;
// If the user wants to trim field values, trim the value
val = options.TRIM_FIELD_VALUES && !_.isNull(val) ? val.trim() : val;
// If the value is an array representation, convert it
if (isArrayRepresentation(val)) {
val = convertArrayRepresentation(val);
}
// Otherwise add the key and value to the document
return path.setPath(document, key.value, val);
}, {});
}
return keys.reduce((document, key) => {
// If there is a value at the key's index in the line, set the value; otherwise null
let value = retrieveRecordValueFromLine(line, key);
// Otherwise add the key and value to the document
return path.setPath(document, key.value, value);
}, {});
}