function | since v1.10.514 | Edit |
(datafy x)
Attempts to return x as data. datafy will return the value of clojure.protocols/datafy. If the value has been transformed and the result supports metadata, :clojure.datafy/obj will be set on the metadata to the original value of x.
(defn datafy
[x]
(let [v (p/datafy x)]
(if (identical? v x)
v
(if (implements? IWithMeta v)
(vary-meta v assoc ::obj x
;; Circling back to this at a later date per @dnolen
;; ::class (-> x .-constructor .-name symbol)
)
v))))