Sha256: 68ac82da956c64301e44939fdeb784435ecb6c135ed5e80de9515e190af07594
Contents?: true
Size: 904 Bytes
Versions: 2
Compression:
Stored size: 904 Bytes
Contents
(ns cljs.tagged-literals (:require [clojure.instant :as inst])) (defn read-queue [form] (assert (vector? form) "Queue literal expects a vector for its elements.") (list 'cljs.core/into 'cljs.core.PersistentQueue/EMPTY form)) (defn read-uuid [form] (assert (string? form) "UUID literal expects a string as its representation.") (try (let [uuid (java.util.UUID/fromString form)] (list (symbol "UUID.") form)) (catch Throwable e (throw (RuntimeException. (.getMessage e)))))) (defn read-inst [form] (assert (string? form) "Instance literal expects a string for its timestamp.") (try (let [^java.util.Date d (inst/read-instant-date form)] (list (symbol "js/Date.") (.getTime d))) (catch Throwable e (throw (RuntimeException. (.getMessage e)))))) (def ^:dynamic *cljs-data-readers* {'queue read-queue 'uuid read-uuid 'inst read-inst})
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
clementine-0.0.3 | ext/clojure-clojurescript-bef56a7/src/clj/cljs/tagged_literals.clj |
clementine-0.0.2 | ext/clojure-clojurescript-bef56a7/src/clj/cljs/tagged_literals.clj |