- Notifications
You must be signed in to change notification settings - Fork0
Tools to aid navigating deeply nested Clojure data structures from code or the REPL.
License
fuse-code/clojure-navigation
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
- Each appropriate command pretty-prints the first 20 rows of the current data structure.
- Data structure listings are automatically paged so you're less likely to blow up your REPLby inadvertently listing a huge data structure.
- At the same time, the current object pointed-to by the (pwd) is always available so you canmap, mapcat, reduce, and grep the actual objects to your heart's content.
(mount data-structure) (cd:child-node1:another-child ...) (cd"..") (ls) (pwd) (current); return the current object (current:sub1:sub2 ...); return the object referenced by :sub1 and :sub2 from (current)
Generally:
(grep matcher root-object)Recursively applies matcher toall children of root-object. When a match is found, the containerof the matched object is returned.
The matcher itself can be any type. If it is a regular expression Pattern, it is matched againststrings or the output of (.toString obj) Strings match any substring of (.toString object).All other objects match using (= matcher obj).
Example:
=> (grep :diffed (current)) [[:diffed {}] [:diffed {}]]In this case, grep searched a data structure that reports differences between two related objects.This run determined that there were no differences found under (current).
(| (range50) inc #(/ %2) +)
(Experimental module)
Inject behavior before/after/around all forms in a do-style block or thread-lastmacro form (experimental).
For example:
(inject logging (form1) (form2) ...)
Logs each form as it is executed. If a form takes longer than 1/2 second, logs the elapsedtime as well.
Or:
(fns (form1) (form2) ...)Returns a vector containing all forms converted into 0-arg functions. These functions thencan be executed during a map, mapcat, or reduce operation and their results stored, furtherprocessed, logged, etc.
These utilities are designed mainly to enhance REPL usage, so we suggest adding them to your.lein/profiles.clj in the :user or :dev profile or equivalent for your build tool.
One might always want these utilities available, even at runtime. In that case, addingthem to your :user profile would make sense. To do that, merge the following into your:user map in your profiles.clj file.
:user {:repositories [["jitpack""https://jitpack.io"]]:dependencies [[com.github.shopsmart/clojure-navigation"version"]]}where "version" currently is "".
<repositories> <repository> <id>jitpack.io</id><name>Jitpack repo</name><url>https://jitpack.io</url> </repository></repositories>
Copyright © 2015 by ShopSmart, LLC. Licensed under the Eclipse Public License v1.0.
David Orme
About
Tools to aid navigating deeply nested Clojure data structures from code or the REPL.
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Languages
- Clojure100.0%