UNPKG

1.77 kBTypeScriptView Raw
1/**
2 * Converts arbitrary values into array objects.
3 *
4 * ### Example ###
5 *
6 * let value1 = ArrayConverter.toArray([1, 2]); // Result: [1, 2]
7 * let value2 = ArrayConverter.toArray(1); // Result: [1]
8 * let value2 = ArrayConverter.listToArray("1,2,3"); // Result: ["1", "2", "3"]
9 */
10export declare class ArrayConverter {
11 /**
12 * Converts value into array object.
13 * Single values are converted into arrays with a single element.
14 *
15 * @param value the value to convert.
16 * @returns array object or null when value is null.
17 */
18 static toNullableArray(value: any): any[];
19 /**
20 * Converts value into array object with empty array as default.
21 * Single values are converted into arrays with single element.
22 *
23 * @param value the value to convert.
24 * @returns array object or empty array when value is null.
25 *
26 * @see [[toNullableArray]]
27 */
28 static toArray(value: any): any[];
29 /**
30 * Converts value into array object with specified default.
31 * Single values are converted into arrays with single element.
32 *
33 * @param value the value to convert.
34 * @param defaultValue default array object.
35 * @returns array object or default array when value is null.
36 *
37 * @see [[toNullableArray]]
38 */
39 static toArrayWithDefault(value: any, defaultValue: any[]): any[];
40 /**
41 * Converts value into array object with empty array as default.
42 * Strings with comma-delimited values are split into array of strings.
43 *
44 * @param value the list to convert.
45 * @returns array object or empty array when value is null
46 *
47 * @see [[toArray]]
48 */
49 static listToArray(value: any): any[];
50}