Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
allFields.forEach(field => {
// Skip if the field is not wanted
if (wantedFields && wantedFields.indexOf(field.name) === -1) return;
// Skip if hidden
if (field.hidden === true) return;
const value = _.get(doc, field.columnName || field.name);
// Virtual or formatted field
if (_.isFunction(field.get)) {
const value = field.get.call(this, value, doc, ctx);
if (isPromise(value))
promises.push(value.then(v => setValue(res, field, v)));
else
setValue(res, field, value);
return;
}
if (value !== undefined) {
setValue(res, field, value);
}
});
const callCustomFn = (field, fn, args) => {
const value = fn.apply(this, args);
if (isPromise(value))
promises.push(value.then(v => setValue(field, v)));
else
setValue(field, value);
};