@@ -3,26 +3,21 @@ function id(_) {
3
3
}
4
4
5
5
const DEFAULTS = {
6
- types : { } ,
6
+ types : Object . create ( null ) ,
7
7
objDelimiter : '.' ,
8
8
mapDelimiter : ':' ,
9
9
preFilters : [ ] ,
10
10
postFilters : [ ]
11
11
}
12
12
13
- const compose = ( ...fns ) => ( res , ...args ) =>
14
- fns . reduceRight ( ( accum , next ) => next ( accum , ...args ) , res )
13
+ const compose = ( ...fns ) => ( i , ...args ) =>
14
+ fns . reduceRight ( ( a , n ) => n ( a , ...args ) , i )
15
15
16
16
const createRootObj = n =>
17
17
isNaN ( n ) ? Object . create ( null ) : new Array ( Number ( n ) )
18
18
19
- const normalizeField = delimiter => m => {
20
- if ( m . indexOf ( delimiter ) > - 1 ) {
21
- return m . split ( delimiter )
22
- }
23
-
24
- return [ m , m ]
25
- }
19
+ const normalizeField = delimiter => m =>
20
+ m . indexOf ( delimiter ) > - 1 ? m . split ( delimiter ) : [ m , m ]
26
21
27
22
const getMapSpec = delimiter => {
28
23
const normalizer = normalizeField ( delimiter )
@@ -54,7 +49,6 @@ const get = (key, delimiter = DEFAULTS.objDelimiter) => {
54
49
if ( key == null ) return id
55
50
56
51
const spec = key . split ( delimiter )
57
-
58
52
return obj => spec . reduce ( ( a , k ) => ( a ? a [ k ] : undefined ) , obj )
59
53
}
60
54
@@ -74,7 +68,7 @@ const assign = (key, delimiter = DEFAULTS.objDelimiter) => {
74
68
75
69
class Mapper {
76
70
constructor ( options ) {
77
- this . config = Object . assign ( { } , DEFAULTS , options )
71
+ this . config = Object . assign ( Object . create ( null ) , DEFAULTS , options )
78
72
this . getMapSpec = getMapSpec ( this . config . mapDelimiter )
79
73
80
74
this . mapFn = compose (
0 commit comments