Conditions | 4 |
Total Lines | 12 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | import type { ClassNamed, ClassHash } from "./defs" |
||
55 | |||
56 | //TODO Consider returning `undefined` on empty string |
||
57 | function joinWithLead(value: Falsy|ClassHash, arr: undefined | string | readonly string[]) : string { |
||
58 | const str1 = value || "" |
||
59 | if (!(arr && arr.length)) |
||
60 | return str1 |
||
61 | |||
62 | const str2 = typeof arr === "string" ? arr : arr.join(" ") |
||
63 | if (!str1) |
||
64 | return str2 |
||
65 | |||
66 | return `${str1} ${str2}` |
||
67 | } |
||
68 |