UNPKG

1.51 kBTypeScriptView Raw
1/**
2 * Converts arbitrary values into map objects using extended conversion rules:
3 * - Objects: property names as keys, property values as values
4 * - Arrays: element indexes as keys, elements as values
5 *
6 * ### Example ###
7 *
8 * let value1 = MapConverted.toNullableMap("ABC"); // Result: null
9 * let value2 = MapConverted.toNullableMap({ key: 123 }); // Result: { key: 123 }
10 * let value3 = MapConverted.toNullableMap([1,2,3]); // Result: { "0": 1, "1": 2, "2": 3 }
11 */
12export declare class MapConverter {
13 /**
14 * Converts value into map object or returns null when conversion is not possible.
15 *
16 * @param value the value to convert.
17 * @returns map object or null when conversion is not supported.
18 */
19 static toNullableMap(value: any): any;
20 /**
21 * Converts value into map object or returns empty map when conversion is not possible
22 *
23 * @param value the value to convert.
24 * @returns map object or empty map when conversion is not supported.
25 *
26 * @see [[toNullableMap]]
27 */
28 static toMap(value: any): any;
29 /**
30 * Converts value into map object or returns default when conversion is not possible
31 *
32 * @param value the value to convert.
33 * @param defaultValue the default value.
34 * @returns map object or emptu map when conversion is not supported.
35 *
36 * @see [[toNullableMap]]
37 */
38 static toMapWithDefault(value: any, defaultValue: any): any;
39}