In my code, I have two functions that will be added in a lodash flow:
function normalizeFields(fields) {
return _.mapValues( fields, function(value) {
return { 'content': value };
});
}
function mergeModelAndFields(model, normalizedFields) {
return _.merge({}, model, normalizedFields);
}
const processFlow = _.flow(normalizeFields, mergeModelAndFields);
const displayErrorMessage = function(fields, model) {
return processFlow(fields, model);
}
The first function, normalizeFields, only takes one argument. The second function requires two arguments: the value returned from normalizeFields and another parameter called 'model'.
When invoking displayErrorMessage, I pass in two arguments to initiate the flow process. How can I make the second argument available to the second function while also passing the product of the first function? Should I use "curry" in this situation? Can you provide an example?