diff options
author | Haider Ali Punjabi <haiderali@cyberservices.com> | 2023-10-26 19:38:39 +0530 |
---|---|---|
committer | Haider Ali Punjabi <haiderali@cyberservices.com> | 2023-10-26 19:38:39 +0530 |
commit | 7fa0708e0e471c6c04864400f7e212147ba73765 (patch) | |
tree | 822be27a6d89cdb8c9c87ffc3b47e7d0a97a8981 /src/lib/strings/helpers.ts | |
parent | c13b6946bab9600cba670478c2f64771cc75f1af (diff) | |
download | voidsky-7fa0708e0e471c6c04864400f7e212147ba73765.tar.zst |
Added show more for long posts
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 +} |