Created
February 10, 2017 09:41
-
-
Save rauhs/adcba3e8c48d8fd90104540fc85a1bca to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (to-transit [:a :a :aa :aa :aaa :aaa]) | |
| ;; => "[\"~:a\",\"~:a\",\"~:aa\",\"^0\",\"~:aaa\",\"^1\"]" | |
| ;; => keywords >= 2 characters get cached, irregardless of being a map key or not | |
| (to-transit ['a 'a 'aa 'aa 'aaa 'aaa]) | |
| ;; => "[\"~$a\",\"~$a\",\"~$aa\",\"^0\",\"~$aaa\",\"^1\"]" | |
| ;; => same for symbols | |
| (to-transit [{"aaa" "aaa"} {"aaa" "aaa"} | |
| {"aaaa" ""} {"aaaa" ""}]) | |
| ;; => "[[\"^ \",\"aaa\",\"aaa\"],[\"^ \",\"aaa\",\"aaa\"],[\"^ \",\"aaaa\",\"\"],[\"^ \",\"^0\",\"\"]]" | |
| ;; => Strings >= 4 characters get cached | |
| ;; => Map values are never cached | |
| (to-transit [{"aaaa" ?/u0} {"aaaa" ?/u0}]) | |
| ;; => "[[\"^ \",\"aaaa\",\"~u00000000-0000-0000-0000-000000000000\"],[\"^ \",\"^0\",\"~u00000000-0000-0000-0000-000000000000\"]]" | |
| (to-transit [{?/u0 "aaaa"} {?/u0 "aaaa"}]) | |
| ;; => "[[\"^ \",\"~u00000000-0000-0000-0000-000000000000\",\"aaaa\"],[\"^ \",\"^0\",\"aaaa\"]]" | |
| ;; => UUIDs as map keys are also cached! | |
| ;; If you want some map values cached, like a UUID that likely occurs often: | |
| (to-transit [{:object/id (symbol (str ?/u0))} {:object/id (symbol (str ?/u0))}]) | |
| ;; => "[[\"^ \",\"~:object/id\",\"~$00000000-0000-0000-0000-000000000000\"],[\"^ \",\"^0\",\"^1\"]]" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment