MCPcopy Create free account
hub / github.com/angular/components / coerceStringArray

Function coerceStringArray

src/cdk/coercion/string-array.ts:26–40  ·  view source on GitHub ↗
(value: any, separator: string | RegExp = /\s+/)

Source from the content-addressed store, hash-verified

24 * @param separator split-separator if value isn't an array
25 */
26export function coerceStringArray(value: any, separator: string | RegExp = /\s+/): string[] {
27 const result = [];
28
29 if (value != null) {
30 const sourceValues = Array.isArray(value) ? value : `${value}`.split(separator);
31 for (const sourceValue of sourceValues) {
32 const trimmedString = `${sourceValue}`.trim();
33 if (trimmedString) {
34 result.push(trimmedString);
35 }
36 }
37 }
38
39 return result;
40}

Callers 2

panelClassFunction · 0.90

Calls 1

pushMethod · 0.65

Tested by

no test coverage detected