|
2 | 2 | "Pretty-print related utilities.
|
3 | 3 | All functions here are simple wrappers that ensure a consistent API:
|
4 | 4 |
|
5 |
| - * two params - object to print and a map of print options |
| 5 | + * has one and two params signatures - object to print and a map of print options |
6 | 6 | * the keys of the print options map can be strings, as bencode clients can't send keywords
|
7 | 7 | * functions return the printed object as a string"
|
8 | 8 | {:added "0.20.0"}
|
|
14 | 14 | "A simple wrapper around `clojure.pprint/write`.
|
15 | 15 | It provides an API compatible with what nREPL's
|
16 | 16 | pr-values middleware expects for printer functions."
|
17 |
| - [object opts] |
18 |
| - (let [opts (assoc (walk/keywordize-keys opts) :stream nil)] |
19 |
| - (apply pp/write object (vec (flatten (vec opts)))))) |
| 17 | + ([object] |
| 18 | + (pprint object {})) |
| 19 | + ([object opts] |
| 20 | + (let [opts (assoc (walk/keywordize-keys opts) :stream nil)] |
| 21 | + (apply pp/write object (vec (flatten (vec opts))))))) |
20 | 22 |
|
21 | 23 | (def ^:private fipp-printer
|
22 | 24 | (delay
|
23 | 25 | (do
|
24 | 26 | (require 'fipp.edn)
|
25 | 27 | (resolve 'fipp.edn/pprint))))
|
26 | 28 |
|
27 |
| -(defn fipp-pprint [object opts] |
28 |
| - (with-out-str |
29 |
| - (@fipp-printer object (walk/keywordize-keys opts)))) |
| 29 | +(defn fipp-pprint |
| 30 | + ([object] |
| 31 | + (fipp-pprint object {})) |
| 32 | + ([object opts] |
| 33 | + (with-out-str |
| 34 | + (@fipp-printer object (walk/keywordize-keys opts))))) |
30 | 35 |
|
31 | 36 | (def ^:private puget-printer
|
32 | 37 | (delay
|
33 | 38 | (do
|
34 | 39 | (require 'puget.printer)
|
35 | 40 | (resolve 'puget.printer/pprint-str))))
|
36 | 41 |
|
37 |
| -(defn puget-pprint [object opts] |
38 |
| - (@puget-printer object (walk/keywordize-keys opts))) |
| 42 | +(defn puget-pprint |
| 43 | + ([object] |
| 44 | + (puget-pprint object {})) |
| 45 | + ([object opts] |
| 46 | + (@puget-printer object (walk/keywordize-keys opts)))) |
0 commit comments