<commit_before>;; 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) 2016 <NAME> <<EMAIL>>

(ns uxbox.util.transit
  (:require [cognitect.transit :as t]
            [uxbox.util.time :as dt])
  (:import java.io.ByteArrayInputStream
           java.io.ByteArrayOutputStream))

;; --- Point Handling

(defrecord Point [x y])

(def point-write-handler
  (t/write-handler
   (constantly "point")
   #(into {} %)))

(def point-read-handler
  (t/read-handler map->Point))

;; --- Handlers

(def ^:private +reader-handlers+
  (merge dt/+read-handlers+
         {"point" point-read-handler}))

(def ^:private +write-handlers+
  (merge dt/+write-handlers+
         {Point point-write-handler}))

;; --- Public Api

(defn reader
  ([istream]
   (reader istream nil))
  ([istream {:keys [type] :or {type :json}}]
   (t/reader istream type {:handlers +reader-handlers+})))

(defn read!
  "Read value from streamed transit reader."<commit_msg>Remove previously introduced point transit handlers.<commit_after>;; 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) 2016 <NAME> <<EMAIL>>

(ns uxbox.util.transit
  (:require [cognitect.transit :as t]
            [uxbox.util.time :as dt])
  (:import java.io.ByteArrayInputStream
           java.io.ByteArrayOutputStream))

;; --- Handlers

(def ^:private +reader-handlers+
  dt/+read-handlers+)

(def ^:private +write-handlers+
  dt/+write-handlers+)

;; --- Public Api

(defn reader
  ([istream]
   (reader istream nil))
  ([istream {:keys [type] :or {type :json}}]
   (t/reader istream type {:handlers +reader-handlers+})))

(defn read!
  "Read value from streamed transit reader."
{'fraction_non_alphanumeric': 0.15479241414659148, 'fraction_numerical': 0.008200922603792926, 'mean_word_length': 3.4263038548752833, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2330737', 'n_tokens_mistral': 685, 'n_tokens_neox': 649, 'n_words': 202}