mona-dish
    Preparing search index...

    Class Config

    Config, basically an optional wrapper for a json structure (not Side - effect free, since we can alter the internal config state without generating a new config), not sure if we should make it side - effect free since this would swallow a lot of performance and ram

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    absent: Optional<any> = ...

    Accessors

    • get shallowCopy(): Config

      shallow copy getter, copies only the first level, references the deeper nodes in a shared manner

      Returns Config

    • get value(): T

      Returns T

    Methods

    • assigns a single value as array, or appends it to an existing value mapping a single value to array

      usage myConfig.append("foobaz").value = "newValue" myConfig.append("foobaz").value = "newValue2"

      resulting in myConfig.foobaz == ["newValue, newValue2"]

      Parameters

      • ...accessPath: string[]

      Returns IValueHolder<any>

    • appends to an existing entry (or extends into an array and appends) if the condition is met

      Parameters

      • condition: boolean
      • ...accessPath: string[]

      Returns IValueHolder<any>

    • assign a value if the condition is set to true, otherwise skip it

      Parameters

      • condition: boolean

        the condition, the access accessPath into the config

      • ...accessPath: any[]

      Returns IValueHolder<any>

    • gets the current node and if none is present returns a config with a default value

      Parameters

      • defaultVal: any

      Returns Config

    • get if the access path is present (get is reserved as getter with a default, on the current path) TODO will be renamed to something more meaningful and deprecated, the name is ambiguous

      Parameters

      • ...accessPath: string[]

        the access path

      Returns Config

    • additional syntactic sugar which is not part of the usual optional implementation but makes life easier, if you want to sacrifice typesafety and refactoring capabilities in typescript

      Type Parameters

      • R

      Parameters

      • key: string

      Returns Optional<R>

    • simple match, if the first order function call returns true then there is a match, if the value is not present it never matches

      Parameters

      • fn: (item: any) => boolean

        the first order function performing the match

      Returns boolean

    • elvis like typesafe functional save resolver a typesafe option for getIfPresent

      usage myOptional.resolve(value => value.subAttr.subAttr2).orElseLazy(....) if this is resolvable without any errors an Optional with the value is returned if not, then an Optional absent is returned, also if you return Optional absent it is flatmapped into absent

      Type Parameters

      • V

      Parameters

      • resolver: (item: any) => V

        the resolver function, can throw any arbitrary errors, int the error case the resolution goes towards absent

      Returns Optional<V>

    • simple merge for the root configs

      Parameters

      • other: Config
      • overwrite: boolean = true
      • withAppend: boolean = false

      Returns void