aboutsummaryrefslogtreecommitdiff
path: root/src/cashflow/utils.clj
diff options
context:
space:
mode:
authorTim <contact@bytim.eu>2026-02-22 15:25:50 +0100
committerTim <contact@bytim.eu>2026-02-22 15:25:50 +0100
commitf279e20468fb5323c33cbf43346c35ddef7f96e0 (patch)
treec488ee2791296917367f704524fa8e41a0b518ea /src/cashflow/utils.clj
Initial commit
Diffstat (limited to 'src/cashflow/utils.clj')
-rw-r--r--src/cashflow/utils.clj24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/cashflow/utils.clj b/src/cashflow/utils.clj
new file mode 100644
index 0000000..abbd2f9
--- /dev/null
+++ b/src/cashflow/utils.clj
@@ -0,0 +1,24 @@
+(ns cashflow.utils
+ (:require [clojure.string :as cstr]))
+
+(defn- n*string [n string]
+ (when (string? string)
+ (->> (for [_ (range n)] string)
+ (apply str))))
+
+(defn string-min-length
+ "Returns string `s` when length of string is `min-length`, otherwise fills string up with a `filler` character, either before `s` if `position` :before or after `s` if `position` is :after."
+ [s min-length filler position]
+ (when (string? s)
+ (let [filler-string (-> (- min-length (.length s))
+ (n*string filler))]
+ (cond
+ (= position :before)
+ (str filler-string s)
+
+ (= position :after)
+ (str s filler-string)
+
+ :else
+ s))))
+