(value, maxLength = 88)
| 38 | } |
| 39 | |
| 40 | function clipLine(value, maxLength = 88) { |
| 41 | const text = typeof value === "string" ? value.replace(/\s+/g, " ").trim() : ""; |
| 42 | if (text.length <= maxLength) return text; |
| 43 | if (maxLength <= 1) return text.slice(0, maxLength); |
| 44 | return `${text.slice(0, maxLength - 1)}…`; |
| 45 | } |
| 46 | |
| 47 | function asNonNegativeInt(value, fallback = 0) { |
| 48 | if (typeof value !== "number" || !Number.isFinite(value)) return fallback; |
no test coverage detected