Options
All
  • Public
  • Public/Protected
  • All
Menu

Class MapConverter

Converts arbitrary values into map objects using extended conversion rules:

  • Objects: property names as keys, property values as values
  • Arrays: element indexes as keys, elements as values

Example

let value1 = MapConverted.toNullableMap("ABC"); // Result: null
let value2 = MapConverted.toNullableMap({ key: 123 }); // Result: { key: 123 }
let value3 = MapConverted.toNullableMap([1,2,3]); // Result: { "0": 1, "1": 2, "2": 3 }

Hierarchy

  • MapConverter

Index

Methods

Static toMap

  • toMap(value: any): any
  • Converts value into map object or returns empty map when conversion is not possible

    see

    toNullableMap

    Parameters

    • value: any

      the value to convert.

    Returns any

    map object or empty map when conversion is not supported.

Static toMapWithDefault

  • toMapWithDefault(value: any, defaultValue: any): any
  • Converts value into map object or returns default when conversion is not possible

    see

    toNullableMap

    Parameters

    • value: any

      the value to convert.

    • defaultValue: any

      the default value.

    Returns any

    map object or emptu map when conversion is not supported.

Static toNullableMap

  • toNullableMap(value: any): any
  • Converts value into map object or returns null when conversion is not possible.

    Parameters

    • value: any

      the value to convert.

    Returns any

    map object or null when conversion is not supported.

Generated using TypeDoc