From 7fa0708e0e471c6c04864400f7e212147ba73765 Mon Sep 17 00:00:00 2001 From: Haider Ali Punjabi Date: Thu, 26 Oct 2023 19:38:39 +0530 Subject: Added show more for long posts --- src/lib/strings/helpers.ts | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/lib/strings/helpers.ts') 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 +} -- cgit 1.4.1