0.3.2 • Published 7 years ago

typescript-immutable-replicator v0.3.2

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

typescript-immutable-replicator

Typesafe, refactorable cloning and modifying of immutable objects with typescript

NPM

Replicator

Replicator is a tool to replicate and modify immutable objects.

image

Characteristics

typesafe properties

image

typesafe property values

image

chainable

image

refactorable and easy to read

Usage

  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()

Examples

image

image

Behaviour

  • 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.

0.3.2

7 years ago

0.3.1

7 years ago

0.3.0

7 years ago

0.2.1

7 years ago

0.2.0

7 years ago

0.1.4

7 years ago

0.1.3

7 years ago

0.1.2

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago