Skip to content

Commit 3f5cf32

Browse files
authored
Merge pull request #34 from lambdaisland/laurence/add-print-as-pretty-print-fallback
change the default setting of the pretty-print printer
2 parents 89183ce + adbd010 commit 3f5cf32

File tree

3 files changed

+31
-3
lines changed

3 files changed

+31
-3
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
## Changed
88

9+
- [breaking] Change the default setting of the pretty-print printer to system printer.
10+
911
# 2.4.138 (2022-09-01 / 6196130)
1012

1113
## Fixed
@@ -126,4 +128,4 @@
126128

127129
## Added
128130

129-
- Extracted from Kaocha, and added a top-level namespace.
131+
- Extracted from Kaocha, and added a top-level namespace.

README.md

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,32 @@ You can register print handlers for new types using
9292
`lambdaisland.deep-diff2.printer/register-print-handler!`, or by passing and
9393
`:extra-handlers` map to `printer`.
9494

95+
Note: the default printer is initialized as `(ddiff/printer {:print-fallback :print})` so that it will fall back to system printer when there is no match.
96+
97+
### Time, data literal
98+
99+
One of the creative ways of using deep-diff is to diff two time data.
100+
101+
```
102+
(ddiff/diff #inst "2019-04-09T14:57:46.128-00:00"
103+
#inst "2019-04-10T14:57:46.128-00:00")
104+
```
105+
or
106+
```
107+
(import '[java.sql Timestamp])
108+
(ddiff/diff (Timestamp. 0)
109+
(doto (Timestamp. 1000) (.setNanos 101)))
110+
```
111+
112+
If you need to diff a rich set of time literal, using [time-literals](https://github.com/henryw374/time-literals) is probably a good choice.
113+
114+
```
115+
(require '[time-literals.read-write])
116+
(require '[lambdaisland.deep-diff2 :as ddiff])
117+
(time-literals.read-write/print-time-literals-clj!)
118+
(ddiff/pretty-print (ddiff/diff #time/date "2039-01-01" #time/date-time "2018-07-05T08:08:44.026"))
119+
```
120+
95121
## Deep-diff 1 vs 2
96122

97123
The original deep-diff only worked on Clojure, not ClojureScript. In porting the
@@ -170,4 +196,4 @@ Another library that implements a form of data structure diffing is [editscript]
170196
Copyright © 2018-2020 Arne Brasseur and contributors
171197

172198
Available under the terms of the Eclipse Public License 1.0, see LICENSE.txt
173-
<!-- /license -->
199+
<!-- /license -->

src/lambdaisland/deep_diff2.cljc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
`:extra-handlers` (a map from symbol to function), or by
2727
using [[lambdaisland.deep-diff.printer/register-print-handler!]]"
2828
([]
29-
(printer {}))
29+
(printer {:print-fallback :print}))
3030
([opts]
3131
(printer-impl/puget-printer opts)))
3232

0 commit comments

Comments
 (0)