Skip to content

Commit 752abd6

Browse files
committed
Clean up getMappingFilter()
1 parent e6926ff commit 752abd6

1 file changed

Lines changed: 5 additions & 8 deletions

File tree

index.js

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,10 @@ const getMapSpec = (mapping, delimiter) =>
5959
const normalizeMapping = mapping =>
6060
typeof mapping === 'string' ? { field: mapping } : mapping
6161

62-
const getMappingFilter = (mapping, types) => {
63-
if (mapping.type) {
64-
if (Array.isArray(mapping.type)) return compose(...mapping.type)
65-
if (typeof mapping.type === 'function') return mapping.type
66-
if (Object.prototype.hasOwnProperty.call(types, mapping.type))
67-
return types[mapping.type]
68-
}
62+
const getMappingFilter = (type, types) => {
63+
if (Array.isArray(type)) return compose(...type)
64+
if (typeof type === 'function') return type
65+
if (Object.prototype.hasOwnProperty.call(types, type)) return types[type]
6966
return id
7067
}
7168

@@ -108,7 +105,7 @@ class Mapper {
108105
assign(targetField, this.config.objDelimiter).bind(this, accum),
109106
/* End user-land transforms */
110107
...this.config.postFilters,
111-
getMappingFilter(mapping, this.config.types),
108+
getMappingFilter(mapping.type, this.config.types),
112109
...this.config.preFilters,
113110
/* Begin user-land transforms */
114111
map(field => get(field, this.config.objDelimiter)(curr))

0 commit comments

Comments
 (0)