From 7b3ab2287a199133acb0f055ca846ace25e45891 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Tue, 19 Apr 2022 12:07:06 +0200 Subject: [PATCH] :tada: Backport pprint module to common --- common/src/app/common/pprint.cljc | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 common/src/app/common/pprint.cljc diff --git a/common/src/app/common/pprint.cljc b/common/src/app/common/pprint.cljc new file mode 100644 index 0000000000..46ed119c72 --- /dev/null +++ b/common/src/app/common/pprint.cljc @@ -0,0 +1,26 @@ +;; This Source Code Form is subject to the terms of the Mozilla Public +;; License, v. 2.0. If a copy of the MPL was not distributed with this +;; file, You can obtain one at http://mozilla.org/MPL/2.0/. +;; +;; Copyright (c) UXBOX Labs SL + +(ns app.common.pprint + (:refer-clojure :exclude [prn]) + (:require + [fipp.edn :as fpp])) + +(defn pprint-str + [expr] + (binding [*print-level* 8 + *print-length* 25] + (with-out-str + (fpp/pprint expr {:width 110})))) + +(defn pprint + ([expr] + (println (pprint-str expr))) + ([label expr] + (println (str "============ " label "============")) + (pprint expr))) + +