From 2ff8ca1af179185b13b922ead124a91614862dcb Mon Sep 17 00:00:00 2001 From: Herbert Wolverson Date: Tue, 3 Dec 2024 09:15:40 -0600 Subject: [PATCH] Add a trim-to-fit function for strings. --- helpers/text_utils.js | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 helpers/text_utils.js diff --git a/helpers/text_utils.js b/helpers/text_utils.js new file mode 100644 index 00000000..f4bb339e --- /dev/null +++ b/helpers/text_utils.js @@ -0,0 +1,4 @@ +export function TrimToFit(s, limit=20) { + if (s.length < limit) return s; + return s.slice(0, limit); +} \ No newline at end of file