UNPKG

1.67 kBTypeScriptView Raw
1/**
2 * Converts arbitrary values into map objects using extended conversion rules.
3 * This class is similar to [[MapConverter]], but is recursively converts all values
4 * stored in objects and arrays.
5 *
6 * ### Example ###
7 *
8 * let value1 = RecursiveMapConverted.toNullableMap("ABC"); // Result: null
9 * let value2 = RecursiveMapConverted.toNullableMap({ key: 123 }); // Result: { key: 123 }
10 * let value3 = RecursiveMapConverted.toNullableMap([1,[2,3]); // Result: { "0": 1, { "0": 2, "1": 3 } }
11 */
12export declare class RecursiveMapConverter {
13 private static objectToMap;
14 private static valueToMap;
15 private static mapToMap;
16 private static arrayToMap;
17 /**
18 * Converts value into map object or returns null when conversion is not possible.
19 *
20 * @param value the value to convert.
21 * @returns map object or null when conversion is not supported.
22 */
23 static toNullableMap(value: any): any;
24 /**
25 * Converts value into map object or returns empty map when conversion is not possible
26 *
27 * @param value the value to convert.
28 * @returns map object or empty map when conversion is not supported.
29 *
30 * @see [[toNullableMap]]
31 */
32 static toMap(value: any): any;
33 /**
34 * Converts value into map object or returns default when conversion is not possible
35 *
36 * @param value the value to convert.
37 * @param defaultValue the default value.
38 * @returns map object or emptu map when conversion is not supported.
39 *
40 * @see [[toNullableMap]]
41 */
42 static toMapWithDefault(value: any, defaultValue: any): any;
43}