Fork me on GitHub
#announcements
<
2024-03-22
>
roboli21:03:45

Hi everyone. I added some bug fixes and improvements to my tiny library https://github.com/roboli/balloon. Recursion is now exclusively used for inflating a map, not as before that it did a pre deflate on complex maps (yes, it kind of cheated). This will leave other parts of your map alone:

(def test-m {:value ["a" "b" "c"]
             :other.0 "any"})

;; Before
(inflate test-m :hash-map true) ;;=> {:value {0 "a", 1 "b", 2 "c"}, :other {0 "any"}}

;; Now
(inflate test-m :hash-map true) ;;=> {:value ["a" "b" "c"], :other {0 "any"}}
You can now use the "/" as a delimiter:
(inflate {:user/id 1 :user/name "Sean" :user/address_id 2 :address/id 2} :delimiter "/")
;;=> {:user {:id 1, :name "Sean", :address_id 2}, :address {:id 2}}
And finally, the library is now Clojurescript compatible. Things don't break until people start using them, so please give it go. Also, comments, suggestions and contributions are very welcome. Thanks.

🎉 2
vemv06:03:12

Nice lib! Does it work with ns-qualified keywords? I'm asking because it's fairly common for backends to work with ns-qualified keywords, and for a JS frontend to not want them, desiring nested objects instead. e.g. input:

{:my-map/one 1}
output:
{:my-map {:one 1}}

roboli14:03:57

Yes it does @U45T93RA6, just pass in the :delimeter "/" flag and it will treat the slash as a delimeter, not as a qualifier.

vemv14:03:29

Neat - I should play with it for testing out some variations e.g. some.other/map (. and /)

p-himik14:03:16

Or (keyword "///"). :D

roboli14:03:47

Okay, one note. This wasn't working:

(deflate {:user {:id 1}} :delimiter "/")
;;=> #:user{:id 1}
I pushed fix in 0.2.3. Now it does correctly:
(deflate {:user {:id 1}} :delimiter "/")
;;=> {:user/id 1}

✅ 1
avfonarev10:03:59

Wrong version number in the announcement...

✅ 1