From 4a242170a0dbc3df30ba56608a581ab1a9fcf61c Mon Sep 17 00:00:00 2001 From: Asko Nomm Date: Sun, 7 Dec 2025 01:18:18 +0200 Subject: Simplify conditional --- src/dompa/nodes.cljc | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'src/dompa/nodes.cljc') diff --git a/src/dompa/nodes.cljc b/src/dompa/nodes.cljc index 3e5c72f..d2f8e4b 100644 --- a/src/dompa/nodes.cljc +++ b/src/dompa/nodes.cljc @@ -132,18 +132,26 @@ attrs? (assoc :node/attrs attrs) (seq children) (assoc :node/children (flatten children)))))) +(defn- list-of-one? + [coll] + (and (sequential? coll) + (= (count coll) 1))) + +(defn- list-of-many? + [coll] + (and (sequential? coll) + (> (count coll) 1))) + (defn- nodes-from-opt [opt] (cond (map? opt) opt - (and (sequential? opt) - (> (count opt) 1)) + (list-of-many? opt) {:node/name :<> :node/children opt} - (and (sequential? opt) - (= (count opt) 1)) + (list-of-one? opt) (first opt) :else -- cgit v1.2.3