typescript-immutable-replicator
Typesafe, refactorable cloning and modifying of immutable objects with typescript

Replicator
Replicator is a tool to replicate and modify immutable objects.
!
image
$3
###### typesafe properties
!
image
###### typesafe property values
!
image
###### chainable
!
image
###### refactorable and easy to read
$3
1. Load an object by calling
ReplicationBuilder.forObject()
2. Navigate down the object tree through the typesafe function
getChild()
3. Modify a property with either
-
modify('prop').to(newValue:T) or
-
modify('prop').by((T) => newValue:T) for example
((oldValue) => oldValue + newValue)
4. Repeat step 3 and 4 until all modifications are done
5. Produce the replica with
build()
$3
!
image
!
image
$3
- deep copies the source object
- freeze in --> freeze out. If the source object was frozen (for detecting manipulations while development), then the produced replica will also be deep frozen.
- warning if source object is not deep frozen (produced replica will be deep frozen)
DeepFreeze
deepFreeze() applies Object.freeze() recursively on an object to make it immutable
isDeepFrozen() checks if an object is recursively frozen.