fix(perf): faster kebab-case to camel-case conversion

This commit is contained in:
Andelf
2022-12-31 01:16:53 +08:00
committed by Tienson Qin
parent dca90ed768
commit 6fa862a954

View File

@@ -12,10 +12,7 @@
(defn kebab-case->camel-case
"Converts from kebab case to camel case, eg: on-click to onClick"
[input]
(let [words (s/split input #"-")
capitalize (->> (rest words)
(map #(apply str (s/upper-case (first %)) (rest %))))]
(apply str (first words) capitalize)))
(s/replace input #"-([a-z])" (fn [[_ c]] (s/upper-case c))))
(defn map-keys->camel-case
"Stringifys all the keys of a cljs hashmap and converts them