ts-data-forge
    Preparing search index...

    Function mapNullable

    • Applies a function to a value if the value is not null or undefined. If the value is null or undefined, it returns undefined.

      This function provides a safe way to transform nullable values without explicit null checks. It's similar to Optional.map() but works directly with TypeScript's nullable types. Supports both regular and curried usage for functional composition.

      Type Parameters

      • const A

        The type of the input value (excluding null/undefined)

      • const B

        The type of the value returned by the mapping function

      Parameters

      • value: A | null | undefined

        The value to potentially transform (can be A, null, or undefined)

      • mapFn: (v: A) => B

        A function that transforms a non-nullable value of type A to type B

      Returns B | undefined

      The result of applying mapFn to value if value is not null/undefined; otherwise undefined

      • Optional - For more complex optional value handling
      • Result - For error handling with detailed error information
    • Applies a function to a value if the value is not null or undefined. If the value is null or undefined, it returns undefined.

      This function provides a safe way to transform nullable values without explicit null checks. It's similar to Optional.map() but works directly with TypeScript's nullable types. Supports both regular and curried usage for functional composition.

      Type Parameters

      • const A

        The type of the input value (excluding null/undefined)

      • const B

        The type of the value returned by the mapping function

      Parameters

      • mapFn: (v: A) => B

        A function that transforms a non-nullable value of type A to type B

      Returns (value: A | null | undefined) => B | undefined

      The result of applying mapFn to value if value is not null/undefined; otherwise undefined

      • Optional - For more complex optional value handling
      • Result - For error handling with detailed error information