Back

camel (clj)

(source)

function

(camel s)
Output will be: lowerUpperUpperNoSpaces accepts strings and keywords

Examples

penpot/penpot
(ns app.main.ui.icons
  (:require
   [clojure.core :as c]
   [cuerdas.core :as str]
   [rumext.v2]))

(defmacro collect-icons
  []
  (let [ns-info (:ns &env)]
    `(cljs.core/js-obj
      ~@(->> (:defs ns-info)
             (map val)
             (filter (fn [entry] (-> entry :meta :icon)))
             (mapcat (fn [{:keys [name] :as entry}]
                       [(-> name c/name str/camel str/capital) name]))))))
teknql/wing
(ns wing.malli.json-test
  (:require [wing.malli.json :as sut]
            #?(:clj [clojure.test :as t :refer [deftest testing is]]
               :cljs [cljs.test :as t :refer [deftest testing is] :include-macros true])
            [malli.core :as m]
            [malli.generator :as mg]
            [cuerdas.core :as str]
            [wing.malli :as wm]))

    (testing "custom string functions"
      (let [opts         {:json/encode-map-key str/camel
                          :json/encode-enum    str/camel}
            transformer  (sut/transformer)
            person->json (m/encoder person-schema opts transformer)
            json->person (m/decoder person-schema opts transformer)
            data         (assoc data :person/eye-color :color/blue-green)
            encoded      (person->json data)
            decoded      (json->person encoded)]
        (is (= data decoded))
        (is (contains? encoded "petName"))
        (is (= "blueGreen" (get encoded "eyeColor")))))))