Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | 657x 116x 541x 541x 541x 794x 1x 793x 793x 10x 783x 783x 541x | /**
* Returns a stable unique array of non-empty string values: entries are
* trimmed, non-strings and duplicates are dropped, and the input order is
* preserved. Non-array inputs yield an empty array, making this safe for
* unvalidated settings values.
*/
export function toUniqueStringArray(value: unknown): string[] {
if (!Array.isArray(value)) {
return [];
}
const seen = new Set<string>();
const result: string[] = [];
for (const entry of value) {
if (typeof entry !== 'string') {
continue;
}
const trimmed = entry.trim();
if (!trimmed || seen.has(trimmed)) {
continue;
}
seen.add(trimmed);
result.push(trimmed);
}
return result;
}
|