1
- import * as _ from 'lodash'
1
+ import * as _cloneDeep from 'lodash.clonedeep'
2
+ import * as _set from 'lodash.set'
3
+ import * as _get from 'lodash.get'
2
4
import { deepFreeze , isDeepFrozen } from './deepFreeze'
3
5
4
6
/**
@@ -16,7 +18,7 @@ export class ReplicationBuilder<T> {
16
18
* @param {RT } sourceObject traversing object
17
19
*/
18
20
private constructor ( sourceObject : T ) {
19
- this . replica = _ . cloneDeep ( sourceObject ) ;
21
+ this . replica = _cloneDeep ( sourceObject ) ;
20
22
this . freeze = Object . isFrozen ( sourceObject ) ;
21
23
if ( this . freeze && ! isDeepFrozen ( sourceObject ) ) {
22
24
console . warn ( 'Source object is frozen but not deep frozen. Please care that always deepFreeze() is used to recursively freeze the object' )
@@ -181,7 +183,7 @@ export class PropertyModifier<PT, VT> {
181
183
* @returns {PT }
182
184
*/
183
185
with ( value : VT ) : PT {
184
- _ . set ( this . replica , this . relativePathToRoot , value ) ;
186
+ _set ( this . replica , this . relativePathToRoot , value ) ;
185
187
return this . parent
186
188
}
187
189
@@ -191,7 +193,7 @@ export class PropertyModifier<PT, VT> {
191
193
* @returns PT this
192
194
*/
193
195
by ( setFunction : ( VT ) => VT ) : PT {
194
- let currentvalue = _ . get ( this . replica , this . relativePathToRoot ) ;
196
+ let currentvalue = _get ( this . replica , this . relativePathToRoot ) ;
195
197
let value = setFunction ( currentvalue ) ;
196
198
return this . with ( value )
197
199
}
@@ -202,7 +204,7 @@ export class PropertyModifier<PT, VT> {
202
204
* @returns {PT }
203
205
*/
204
206
withCloneAndDo ( executeOnCloneFunction : ( VT ) => void ) : PT {
205
- let currentvalue = _ . get ( this . replica , this . relativePathToRoot ) ;
207
+ let currentvalue = _get ( this . replica , this . relativePathToRoot ) ;
206
208
executeOnCloneFunction ( currentvalue ) ;
207
209
return this . parent ;
208
210
}
0 commit comments