mona-dish
    Preparing search index...

    Class ValueEmbedder<T>

    ValueEmbedder is the writeable version of optional, it basically is a wrapper around a construct which has a state and can be written to.

    For the readonly version see Optional

    Type Parameters

    • T

    Hierarchy (View Summary)

    Implements

    Index

    Constructors

    Properties

    absent: Optional<unknown> = ...

    Accessors

    Methods

    • convenience function to flatmap the internal value and replace it with a default in case of being absent

      Type Parameters

      • R

      Parameters

      • defaultVal: any = Optional.absent

      Returns Optional<R>

    • 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: T) => 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: T) => V

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

      Returns Optional<V>