Skip to content

Commit

Permalink
Move if condition outside of map (#29)
Browse files Browse the repository at this point in the history
The map only needs to be done when there is a matching type in the config for the current key.
  • Loading branch information
beaubbe authored and nitriques committed Feb 16, 2018
1 parent 5ba2e59 commit 0a96c81
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions lib/process.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,10 @@ const parse = (record, data, config) => {
}

// A type converter for this key does exists
if (!!config.types && !!config.types[key]) {
if (!!config.types && !!config.types[key] && !!types[config.types[key]]) {
// Cast all values
record[key] = _.map(record[key], (value) => {
if (!!types[config.types[key]]) {
return types[config.types[key]](value);
}
return types[config.types[key]](value);
});
}

Expand Down

0 comments on commit 0a96c81

Please sign in to comment.