Class Config

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

Hierarchy

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 stream(): Stream<[string, any]>
  • returns the first config level as streeam

    Returns Stream<[string, any]>

  • 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

    • Rest ...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
    • Rest ...accessPath: string[]

    Returns IValueHolder<any>

  • assings an new value on the given access path

    Parameters

    • Rest ...accessPath: any[]

    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

    • Rest ...accessPath: any[]

    Returns IValueHolder<any>

  • Type Parameters

    • R

    Parameters

    • Optional fn: ((data: any) => R)
        • (data: any): R
        • Parameters

          • data: any

          Returns R

    Returns Optional<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 ambigous

    Parameters

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

  • any value present

    Parameters

    • Optional presentRunnable: ((val?: Monad<any>) => void)
        • (val?: Monad<any>): void
        • Parameters

          • Optional val: Monad<any>

          Returns void

    Returns boolean

  • Type Parameters

    • R

    Parameters

    • Optional fn: ((data: any) => R)
        • (data: any): R
        • Parameters

          • data: any

          Returns R

    Returns Monad<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

        • (item: any): boolean
        • Parameters

          • item: any

          Returns boolean

    Returns boolean

  • lazy, passes a function which then is lazily evaluated instead of a direct value

    Parameters

    • func: (() => any)
        • (): any
        • Returns any

    Returns Optional<any>

  • 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

        • (item: any): V
        • Parameters

          • item: any

          Returns V

    Returns Optional<V>

  • simple merge for the root configs

    Parameters

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

    Returns void

Generated using TypeDoc