@@ -8,16 +8,16 @@ import {deepFreeze, isDeepFrozen} from './deepFreeze'
88 * Warns if source object is just frozen, not deep frozen
99 **/
1010export class ReplicationBuilder < T > {
11- private replica : T = null
12- private freeze = false
11+ private replica : T = null ;
12+ private freeze = false ;
1313
1414 /**
1515 * default constructor
1616 * @param {RT } sourceObject traversing object
1717 */
1818 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 ) ;
2121 if ( this . freeze && ! isDeepFrozen ( sourceObject ) ) {
2222 console . warn ( 'Source object is frozen but not deep frozen. Please care that always deepFreeze() is used to recursively freeze the object' )
2323 }
@@ -31,12 +31,12 @@ export class ReplicationBuilder<T> {
3131 * @param {K } childNode of the root node
3232 * @returns {ReplicaChildOperator<T, T[K]> } operator of child node
3333 **/
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 ] ;
3636 return new ReplicaChildOperator ( ( ( ) => this . build ( ) ) , this . replica , node , childNode )
3737 }
3838
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 ] > {
4040 return new PropertyModifier < ReplicationBuilder < T > , T [ K ] > ( this , childNode , this . replica )
4141 }
4242
@@ -65,14 +65,14 @@ export class ReplicationBuilder<T> {
6565 * Operator for nodes of the replica
6666 */
6767export class ReplicaChildOperator < RT , T > {
68- private buildFunction : ( ) => RT
69- private node : T
68+ private buildFunction : ( ) => RT ;
69+ private node : T ;
7070 private replica : RT ;
7171 private relativePath ;
7272
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 ;
7676 this . replica = replica ;
7777 this . relativePath = relativePath ;
7878 }
@@ -82,7 +82,7 @@ export class ReplicaChildOperator<RT, T> {
8282 * @returns {ReplicaChildOperator<RT, N[K]> } traversable child node
8383 **/
8484 getChild < K extends keyof T > ( childNode : K ) : ReplicaChildOperator < RT , T [ K ] > {
85- let branch = this . node [ childNode ]
85+ let branch = this . node [ childNode ] ;
8686 return new ReplicaChildOperator ( this . buildFunction , this . replica , branch , this . relativePath + '.' + childNode )
8787 }
8888
@@ -108,13 +108,13 @@ export class ReplicaChildOperator<RT, T> {
108108}
109109
110110export 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 ;
114114
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 ;
118118 this . relativePathToRoot = relativePathToRoot
119119 }
120120
@@ -124,7 +124,7 @@ export class PropertyModifier<PT, VT> {
124124 * @returns {PT }
125125 */
126126 to ( value : VT ) : PT {
127- _ . set ( this . replica , this . relativePathToRoot , value )
127+ _ . set ( this . replica , this . relativePathToRoot , value ) ;
128128 return this . parent
129129 }
130130
@@ -134,8 +134,8 @@ export class PropertyModifier<PT, VT> {
134134 * @returns PT this
135135 */
136136 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 ) ;
139139 return this . to ( value )
140140 }
141141}
0 commit comments