@mikuroxina/mini-fn
    Preparing search index...

    Function mapOr

    • Maps the optional value with a default value init.

      Type Parameters

      • U

      Parameters

      • init: U

        The default value.

      Returns <T>(f: (t: T) => U) => (opt: Option.Option<T>) => U

      The mapped value or init.

      Examples

      const strLenOrAnswer = mapOr(42)((str: string) => str.length);

      expect(strLenOrAnswer(some("Hello, World!"))).toStrictEqual(13);
      expect(strLenOrAnswer(none())).toStrictEqual(42);