@@ -8,16 +8,16 @@ import {deepFreeze, isDeepFrozen} from './deepFreeze'
8
8
* Warns if source object is just frozen, not deep frozen
9
9
**/
10
10
export class ReplicationBuilder < T > {
11
- private replica : T = null
12
- private freeze = false
11
+ private replica : T = null ;
12
+ private freeze = false ;
13
13
14
14
/**
15
15
* default constructor
16
16
* @param {RT } sourceObject traversing object
17
17
*/
18
18
private constructor ( sourceObject : T ) {
19
- this . replica = _ . cloneDeep ( sourceObject )
20
- this . freeze = Object . isFrozen ( sourceObject )
19
+ this . replica = _ . cloneDeep ( sourceObject ) ;
20
+ this . freeze = Object . isFrozen ( sourceObject ) ;
21
21
if ( this . freeze && ! isDeepFrozen ( sourceObject ) ) {
22
22
console . warn ( 'Source object is frozen but not deep frozen. Please care that always deepFreeze() is used to recursively freeze the object' )
23
23
}
@@ -31,12 +31,12 @@ export class ReplicationBuilder<T> {
31
31
* @param {K } childNode of the root node
32
32
* @returns {ReplicaChildOperator<T, T[K]> } operator of child node
33
33
**/
34
- public getChild < K extends Extract < keyof T , string > > ( childNode : K ) : ReplicaChildOperator < T , T [ K ] > {
35
- let node = this . replica [ childNode ]
34
+ public getChild < K extends keyof T > ( childNode : K ) : ReplicaChildOperator < T , T [ K ] > {
35
+ let node = this . replica [ childNode ] ;
36
36
return new ReplicaChildOperator ( ( ( ) => this . build ( ) ) , this . replica , node , childNode )
37
37
}
38
38
39
- modify < K extends Extract < keyof T , string > > ( childNode : K ) : PropertyModifier < ReplicationBuilder < T > , T [ K ] > {
39
+ modify < K extends keyof T > ( childNode : K ) : PropertyModifier < ReplicationBuilder < T > , T [ K ] > {
40
40
return new PropertyModifier < ReplicationBuilder < T > , T [ K ] > ( this , childNode , this . replica )
41
41
}
42
42
@@ -65,14 +65,14 @@ export class ReplicationBuilder<T> {
65
65
* Operator for nodes of the replica
66
66
*/
67
67
export class ReplicaChildOperator < RT , T > {
68
- private buildFunction : ( ) => RT
69
- private node : T
68
+ private buildFunction : ( ) => RT ;
69
+ private node : T ;
70
70
private replica : RT ;
71
71
private relativePath ;
72
72
73
- constructor ( buildFunction : ( ) => RT , replica : RT , node : T , relativePath : string ) {
74
- this . buildFunction = buildFunction
75
- this . node = node
73
+ constructor ( buildFunction : ( ) => RT , replica : RT , node : T , relativePath : string | number | symbol ) {
74
+ this . buildFunction = buildFunction ;
75
+ this . node = node ;
76
76
this . replica = replica ;
77
77
this . relativePath = relativePath ;
78
78
}
@@ -82,7 +82,7 @@ export class ReplicaChildOperator<RT, T> {
82
82
* @returns {ReplicaChildOperator<RT, N[K]> } traversable child node
83
83
**/
84
84
getChild < K extends keyof T > ( childNode : K ) : ReplicaChildOperator < RT , T [ K ] > {
85
- let branch = this . node [ childNode ]
85
+ let branch = this . node [ childNode ] ;
86
86
return new ReplicaChildOperator ( this . buildFunction , this . replica , branch , this . relativePath + '.' + childNode )
87
87
}
88
88
@@ -108,13 +108,13 @@ export class ReplicaChildOperator<RT, T> {
108
108
}
109
109
110
110
export class PropertyModifier < PT , VT > {
111
- private replica : any
112
- private parent : PT
113
- private relativePathToRoot : string
111
+ private replica : any ;
112
+ private parent : PT ;
113
+ private relativePathToRoot : string | number | symbol ;
114
114
115
- constructor ( parent : PT , relativePathToRoot : string , rootObject : any ) {
116
- this . replica = rootObject
117
- this . parent = parent
115
+ constructor ( parent : PT , relativePathToRoot : string | number | symbol , rootObject : any ) {
116
+ this . replica = rootObject ;
117
+ this . parent = parent ;
118
118
this . relativePathToRoot = relativePathToRoot
119
119
}
120
120
@@ -124,7 +124,7 @@ export class PropertyModifier<PT, VT> {
124
124
* @returns {PT }
125
125
*/
126
126
to ( value : VT ) : PT {
127
- _ . set ( this . replica , this . relativePathToRoot , value )
127
+ _ . set ( this . replica , this . relativePathToRoot , value ) ;
128
128
return this . parent
129
129
}
130
130
@@ -134,8 +134,8 @@ export class PropertyModifier<PT, VT> {
134
134
* @returns PT this
135
135
*/
136
136
by ( setFunction : ( VT ) => VT ) : PT {
137
- let currentvalue = _ . get ( this . replica , this . relativePathToRoot )
138
- let value = setFunction ( currentvalue )
137
+ let currentvalue = _ . get ( this . replica , this . relativePathToRoot ) ;
138
+ let value = setFunction ( currentvalue ) ;
139
139
return this . to ( value )
140
140
}
141
141
}
0 commit comments