Skip to content

Commit 90ce474

Browse files
committed
precompute mapFn
1 parent e93454d commit 90ce474

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

index.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,13 @@ class Mapper {
7878
constructor(options) {
7979
this.config = Object.assign({}, DEFAULTS, options)
8080
this.getMapSpec = getMapSpec(this.config.mapDelimiter)
81+
82+
this.mapFn = compose(
83+
...this.config.postFilters,
84+
(v, m, con, c, a) =>
85+
getMappingFilter(m.type, this.config.types)(v, m, con, c, a),
86+
...this.config.preFilters
87+
)
8188
}
8289

8390
map(mappings, curr, next = Object.create(null)) {
@@ -92,11 +99,7 @@ class Mapper {
9299
value = fn(sourceField)
93100
}
94101

95-
value = compose(
96-
...this.config.postFilters,
97-
getMappingFilter(mapping.type, this.config.types),
98-
...this.config.preFilters
99-
)(value, mapping, this.config, curr, accum)
102+
value = this.mapFn(value, mapping, this.config, curr, accum)
100103

101104
if (value === undefined) {
102105
return accum

0 commit comments

Comments
 (0)