diff options
Diffstat (limited to 'src/lib/strings/helpers.ts')
-rw-r--r-- | src/lib/strings/helpers.ts | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/lib/strings/helpers.ts b/src/lib/strings/helpers.ts index ef93a366f..381ae32f3 100644 --- a/src/lib/strings/helpers.ts +++ b/src/lib/strings/helpers.ts @@ -32,3 +32,8 @@ export function toHashCode(str: string, seed = 0): number { return 4294967296 * (2097151 & h2) + (h1 >>> 0) } + +export function countLines(str: string | undefined): number { + if (!str) return 0 + return str.match(/\n/g)?.length ?? 0 +} |