Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ChangeLookup

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) { ... } `

Hierarchy

  • ChangeLookup

Indexable

[index: string]: boolean | any

Also allow for string-based index access in TypeScript.

const altered = Object.assign(new ChangeLookup(), alterable); altered.alter('data.beta'); if(altered.data.any) { ... } `

Index

Methods

alter

  • alter(path: string): void
  • 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.

    Parameters

    • path: string

      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.

    Returns void

reset

  • reset(): void

Static Protected alter

  • alter(path: string, property: any): void
  • 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.

    Parameters

    • path: string

      Relative path w.r.t. to the given property.

    • property: any

      Property to continue traversal of the given relative path on.

    Returns void

Static Protected reset

  • reset(property: any): void
  • 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).

    Parameters

    • property: any

      Property to reset alteration states of.

    Returns void