@luolapeikko/result-option
    Preparing search index...

    Class Option

    Option with static functions

    v2.0.0

    Index

    Methods

    • resolve all options to single ISome array result or INone

      Type Parameters

      • T extends any[]

      Parameters

      • ...args: AllArgs<T>

        Array of IOptions or Functions return IOption

      Returns INone | ISome<ExtractAllSomeArray<T>>

      • returns ISome or INone
      const test1 = (): ISome<string> => Some('hello');
      const test2 = (): ISome<number> => Some(10);
      const output: ISome<[string, number]> | INone = Option.all(test1, test2);

      v2.0.0

    • resolve all possible async options to single ISome array result or INone

      Type Parameters

      • T extends any[]

      Parameters

      • ...args: AllAsyncArgs<T>

        Array of async IOptions or Functions return IOption

      Returns Promise<INone | ISome<ExtractAllSomeArray<T>>>

      • returns Promise of ISome or INone
      const test1 = (): ISome<string> => Promise.resolve(Some('hello'));
      const test2 = (): ISome<number> => Promise.resolve(Some(10));
      const output: ISome<[string, number]> | INone = await Option.asyncAll(test1, test2);

      v2.0.0

    • from any value to Some(), nullish and NaN will return None()

      Type Parameters

      • ValueType

      Parameters

      • value: undefined | null | ValueType

        value to wrap

      Returns IOption<ValueType>

      • returns Some(value) or None()
      const data: IOption<string> = Option.fromNullish(getStringValueOrNull()) // returns Some(value) or None()
      

      v2.0.0

    • from Number to Some(), nullish and NaN will return None()

      Type Parameters

      • ValueType extends number

        extends number

      Parameters

      • value: undefined | null | ValueType

        value to wrap

      Returns IOption<ValueType>

      • returns Some(value) or None()
      Option.fromNum(parseInt(stringNumber, 10)) // returns Some(value) or None()
      

      v2.0.0