Also allow for string-based index access in TypeScript.
const altered = Object.assign(new ChangeLookup(), alterable); altered.alter('data.beta'); if(altered.data.any) { ... }
Alters the given key as well as the any
element of all parent objects. For example, the key 'foo.bar' would
cause altered.foo.bar
and altered.foo.any
as well as altered.any
to be true. Note that the altered
object should only be modified using this method to avoid erroneous states.
Full object path to the altered key (keys joined using '.', e.g., 'foo.bar'). If the path is referring to an object, the alteration is propagated top-down to all children.
Reset all alteration states to false.
One step of the recursive traversal of a given properties path in order to invalidate the alteration states. Please note, that this is design is not intended for very large structures since no caching is applied.
Relative path w.r.t. to the given property.
Property to continue traversal of the given relative path on.
Resets all nested alteration states of a given parent property recursively. Children of object type are recursively reset. Every other child is directly set to false (including any).
Property to reset alteration states of.
Utility class to replicate the structure of all alterable properties of a class to. This was initially designed to be used in combination with an
alterable
decorator (but instance-based property decoration does not work yet). For now though, this is used for explicit alterable structure replication and management.``` const alterable = { any: false, data: { any: false, alpha: false, beta: false }, modifier: false };
const altered = Object.assign(new ChangeLookup(), alterable); altered.alter('data.beta'); if(altered.data.any) { ... }