UNPKG

1.62 kBTypeScriptView Raw
1/**
2 * Converts arbitrary values into strings using extended conversion rules:
3 * - Numbers: are converted with '.' as decimal point
4 * - DateTime: using ISO format
5 * - Boolean: "true" for true and "false" for false
6 * - Arrays: as comma-separated list
7 * - Other objects: using <code>toString()</code> method
8 *
9 * ### Example ###
10 *
11 * let value1 = StringConverter.ToString(123.456); // Result: "123.456"
12 * let value2 = StringConverter.ToString(true); // Result: "true"
13 * let value3 = StringConverter.ToString(new Date(2018,0,1)); // Result: "2018-01-01T00:00:00.00"
14 * let value4 = StringConverter.ToString([1,2,3]); // Result: "1,2,3"
15 */
16export declare class StringConverter {
17 /**
18 * Converts value into string or returns null when value is null.
19 *
20 * @param value the value to convert.
21 * @returns string value or null when value is null.
22 */
23 static toNullableString(value: any): string;
24 /**
25 * Converts value into string or returns "" when value is null.
26 *
27 * @param value the value to convert.
28 * @returns string value or "" when value is null.
29 *
30 * @see [[toStringWithDefault]]
31 */
32 static toString(value: any): string;
33 /**
34 * Converts value into string or returns default when value is null.
35 *
36 * @param value the value to convert.
37 * @param defaultValue the default value.
38 * @returns string value or default when value is null.
39 *
40 * @see [[toNullableString]]
41 */
42 static toStringWithDefault(value: any, defaultValue: string): string;
43}