Working production build in docs subdirectory.
This commit is contained in:
parent
bb7be028e6
commit
a5204c66b9
644 changed files with 134256 additions and 53616 deletions
|
|
@ -0,0 +1,6 @@
|
|||
#Leiningen
|
||||
#Thu Feb 27 09:21:01 GMT 2020
|
||||
version=0.1.0-SNAPSHOT
|
||||
revision=bb7be028e6b1f2cc752f4c7fd58d2d1a9df58a8d
|
||||
groupId=geocsv-lite
|
||||
artifactId=geocsv-lite
|
||||
11722
resources/public/target/cljsbuild-compiler-1/cljs/core.cljs
Normal file
11722
resources/public/target/cljsbuild-compiler-1/cljs/core.cljs
Normal file
File diff suppressed because it is too large
Load diff
37897
resources/public/target/cljsbuild-compiler-1/cljs/core.js
Normal file
37897
resources/public/target/cljsbuild-compiler-1/cljs/core.js
Normal file
File diff suppressed because it is too large
Load diff
File diff suppressed because one or more lines are too long
|
|
@ -0,0 +1,925 @@
|
|||
(ns cljs.core.async
|
||||
(:refer-clojure :exclude [reduce transduce into merge map take partition partition-by])
|
||||
(:require [cljs.core.async.impl.protocols :as impl]
|
||||
[cljs.core.async.impl.channels :as channels]
|
||||
[cljs.core.async.impl.buffers :as buffers]
|
||||
[cljs.core.async.impl.timers :as timers]
|
||||
[cljs.core.async.impl.dispatch :as dispatch]
|
||||
[cljs.core.async.impl.ioc-helpers :as helpers]
|
||||
[goog.array :as garray])
|
||||
(:require-macros [cljs.core.async.impl.ioc-macros :as ioc]
|
||||
[cljs.core.async :refer [go go-loop]]))
|
||||
|
||||
(defn- fn-handler
|
||||
([f] (fn-handler f true))
|
||||
([f blockable]
|
||||
(reify
|
||||
impl/Handler
|
||||
(active? [_] true)
|
||||
(blockable? [_] blockable)
|
||||
(commit [_] f))))
|
||||
|
||||
(defn buffer
|
||||
"Returns a fixed buffer of size n. When full, puts will block/park."
|
||||
[n]
|
||||
(buffers/fixed-buffer n))
|
||||
|
||||
(defn dropping-buffer
|
||||
"Returns a buffer of size n. When full, puts will complete but
|
||||
val will be dropped (no transfer)."
|
||||
[n]
|
||||
(buffers/dropping-buffer n))
|
||||
|
||||
(defn sliding-buffer
|
||||
"Returns a buffer of size n. When full, puts will complete, and be
|
||||
buffered, but oldest elements in buffer will be dropped (not
|
||||
transferred)."
|
||||
[n]
|
||||
(buffers/sliding-buffer n))
|
||||
|
||||
(defn unblocking-buffer?
|
||||
"Returns true if a channel created with buff will never block. That is to say,
|
||||
puts into this buffer will never cause the buffer to be full. "
|
||||
[buff]
|
||||
(satisfies? impl/UnblockingBuffer buff))
|
||||
|
||||
(defn chan
|
||||
"Creates a channel with an optional buffer, an optional transducer (like (map f),
|
||||
(filter p) etc or a composition thereof), and an optional exception handler.
|
||||
If buf-or-n is a number, will create and use a fixed buffer of that size. If a
|
||||
transducer is supplied a buffer must be specified. ex-handler must be a
|
||||
fn of one argument - if an exception occurs during transformation it will be called
|
||||
with the thrown value as an argument, and any non-nil return value will be placed
|
||||
in the channel."
|
||||
([] (chan nil))
|
||||
([buf-or-n] (chan buf-or-n nil nil))
|
||||
([buf-or-n xform] (chan buf-or-n xform nil))
|
||||
([buf-or-n xform ex-handler]
|
||||
(let [buf-or-n (if (= buf-or-n 0)
|
||||
nil
|
||||
buf-or-n)]
|
||||
(when xform (assert buf-or-n "buffer must be supplied when transducer is"))
|
||||
(channels/chan (if (number? buf-or-n)
|
||||
(buffer buf-or-n)
|
||||
buf-or-n)
|
||||
xform
|
||||
ex-handler))))
|
||||
|
||||
(defn promise-chan
|
||||
"Creates a promise channel with an optional transducer, and an optional
|
||||
exception-handler. A promise channel can take exactly one value that consumers
|
||||
will receive. Once full, puts complete but val is dropped (no transfer).
|
||||
Consumers will block until either a value is placed in the channel or the
|
||||
channel is closed. See chan for the semantics of xform and ex-handler."
|
||||
([] (promise-chan nil))
|
||||
([xform] (promise-chan xform nil))
|
||||
([xform ex-handler]
|
||||
(chan (buffers/promise-buffer) xform ex-handler)))
|
||||
|
||||
(defn timeout
|
||||
"Returns a channel that will close after msecs"
|
||||
[msecs]
|
||||
(timers/timeout msecs))
|
||||
|
||||
(defn <!
|
||||
"takes a val from port. Must be called inside a (go ...) block. Will
|
||||
return nil if closed. Will park if nothing is available.
|
||||
Returns true unless port is already closed"
|
||||
[port]
|
||||
(throw (js/Error. "<! used not in (go ...) block")))
|
||||
|
||||
(defn take!
|
||||
"Asynchronously takes a val from port, passing to fn1. Will pass nil
|
||||
if closed. If on-caller? (default true) is true, and value is
|
||||
immediately available, will call fn1 on calling thread.
|
||||
Returns nil."
|
||||
([port fn1] (take! port fn1 true))
|
||||
([port fn1 on-caller?]
|
||||
(let [ret (impl/take! port (fn-handler fn1))]
|
||||
(when ret
|
||||
(let [val @ret]
|
||||
(if on-caller?
|
||||
(fn1 val)
|
||||
(dispatch/run #(fn1 val)))))
|
||||
nil)))
|
||||
|
||||
(defn- nop [_])
|
||||
(def ^:private fhnop (fn-handler nop))
|
||||
|
||||
(defn >!
|
||||
"puts a val into port. nil values are not allowed. Must be called
|
||||
inside a (go ...) block. Will park if no buffer space is available.
|
||||
Returns true unless port is already closed."
|
||||
[port val]
|
||||
(throw (js/Error. ">! used not in (go ...) block")))
|
||||
|
||||
(defn put!
|
||||
"Asynchronously puts a val into port, calling fn1 (if supplied) when
|
||||
complete. nil values are not allowed. Will throw if closed. If
|
||||
on-caller? (default true) is true, and the put is immediately
|
||||
accepted, will call fn1 on calling thread. Returns nil."
|
||||
([port val]
|
||||
(if-let [ret (impl/put! port val fhnop)]
|
||||
@ret
|
||||
true))
|
||||
([port val fn1] (put! port val fn1 true))
|
||||
([port val fn1 on-caller?]
|
||||
(if-let [retb (impl/put! port val (fn-handler fn1))]
|
||||
(let [ret @retb]
|
||||
(if on-caller?
|
||||
(fn1 ret)
|
||||
(dispatch/run #(fn1 ret)))
|
||||
ret)
|
||||
true)))
|
||||
|
||||
(defn close!
|
||||
([port]
|
||||
(impl/close! port)))
|
||||
|
||||
|
||||
(defn- random-array
|
||||
[n]
|
||||
(let [a (make-array n)]
|
||||
(dotimes [x n]
|
||||
(aset a x x))
|
||||
(garray/shuffle a)
|
||||
a))
|
||||
|
||||
(defn- alt-flag []
|
||||
(let [flag (atom true)]
|
||||
(reify
|
||||
impl/Handler
|
||||
(active? [_] @flag)
|
||||
(blockable? [_] true)
|
||||
(commit [_]
|
||||
(reset! flag nil)
|
||||
true))))
|
||||
|
||||
(defn- alt-handler [flag cb]
|
||||
(reify
|
||||
impl/Handler
|
||||
(active? [_] (impl/active? flag))
|
||||
(blockable? [_] true)
|
||||
(commit [_]
|
||||
(impl/commit flag)
|
||||
cb)))
|
||||
|
||||
(defn do-alts
|
||||
"returns derefable [val port] if immediate, nil if enqueued"
|
||||
[fret ports opts]
|
||||
(assert (pos? (count ports)) "alts must have at least one channel operation")
|
||||
(let [flag (alt-flag)
|
||||
n (count ports)
|
||||
idxs (random-array n)
|
||||
priority (:priority opts)
|
||||
ret
|
||||
(loop [i 0]
|
||||
(when (< i n)
|
||||
(let [idx (if priority i (aget idxs i))
|
||||
port (nth ports idx)
|
||||
wport (when (vector? port) (port 0))
|
||||
vbox (if wport
|
||||
(let [val (port 1)]
|
||||
(impl/put! wport val (alt-handler flag #(fret [% wport]))))
|
||||
(impl/take! port (alt-handler flag #(fret [% port]))))]
|
||||
(if vbox
|
||||
(channels/box [@vbox (or wport port)])
|
||||
(recur (inc i))))))]
|
||||
(or
|
||||
ret
|
||||
(when (contains? opts :default)
|
||||
(when-let [got (and (impl/active? flag) (impl/commit flag))]
|
||||
(channels/box [(:default opts) :default]))))))
|
||||
|
||||
(defn alts!
|
||||
"Completes at most one of several channel operations. Must be called
|
||||
inside a (go ...) block. ports is a vector of channel endpoints,
|
||||
which can be either a channel to take from or a vector of
|
||||
[channel-to-put-to val-to-put], in any combination. Takes will be
|
||||
made as if by <!, and puts will be made as if by >!. Unless
|
||||
the :priority option is true, if more than one port operation is
|
||||
ready a non-deterministic choice will be made. If no operation is
|
||||
ready and a :default value is supplied, [default-val :default] will
|
||||
be returned, otherwise alts! will park until the first operation to
|
||||
become ready completes. Returns [val port] of the completed
|
||||
operation, where val is the value taken for takes, and a
|
||||
boolean (true unless already closed, as per put!) for puts.
|
||||
|
||||
opts are passed as :key val ... Supported options:
|
||||
|
||||
:default val - the value to use if none of the operations are immediately ready
|
||||
:priority true - (default nil) when true, the operations will be tried in order.
|
||||
|
||||
Note: there is no guarantee that the port exps or val exprs will be
|
||||
used, nor in what order should they be, so they should not be
|
||||
depended upon for side effects."
|
||||
|
||||
[ports & {:as opts}]
|
||||
(throw (js/Error. "alts! used not in (go ...) block")))
|
||||
|
||||
(defn offer!
|
||||
"Puts a val into port if it's possible to do so immediately.
|
||||
nil values are not allowed. Never blocks. Returns true if offer succeeds."
|
||||
[port val]
|
||||
(let [ret (impl/put! port val (fn-handler nop false))]
|
||||
(when ret @ret)))
|
||||
|
||||
(defn poll!
|
||||
"Takes a val from port if it's possible to do so immediately.
|
||||
Never blocks. Returns value if successful, nil otherwise."
|
||||
[port]
|
||||
(let [ret (impl/take! port (fn-handler nop false))]
|
||||
(when ret @ret)))
|
||||
|
||||
;;;;;;; channel ops
|
||||
|
||||
(defn pipe
|
||||
"Takes elements from the from channel and supplies them to the to
|
||||
channel. By default, the to channel will be closed when the from
|
||||
channel closes, but can be determined by the close? parameter. Will
|
||||
stop consuming the from channel if the to channel closes"
|
||||
|
||||
([from to] (pipe from to true))
|
||||
([from to close?]
|
||||
(go-loop []
|
||||
(let [v (<! from)]
|
||||
(if (nil? v)
|
||||
(when close? (close! to))
|
||||
(when (>! to v)
|
||||
(recur)))))
|
||||
to))
|
||||
|
||||
(defn- pipeline*
|
||||
([n to xf from close? ex-handler type]
|
||||
(assert (pos? n))
|
||||
(let [jobs (chan n)
|
||||
results (chan n)
|
||||
process (fn [[v p :as job]]
|
||||
(if (nil? job)
|
||||
(do (close! results) nil)
|
||||
(let [res (chan 1 xf ex-handler)]
|
||||
(go
|
||||
(>! res v)
|
||||
(close! res))
|
||||
(put! p res)
|
||||
true)))
|
||||
async (fn [[v p :as job]]
|
||||
(if (nil? job)
|
||||
(do (close! results) nil)
|
||||
(let [res (chan 1)]
|
||||
(xf v res)
|
||||
(put! p res)
|
||||
true)))]
|
||||
(dotimes [_ n]
|
||||
(case type
|
||||
:compute (go-loop []
|
||||
(let [job (<! jobs)]
|
||||
(when (process job)
|
||||
(recur))))
|
||||
:async (go-loop []
|
||||
(let [job (<! jobs)]
|
||||
(when (async job)
|
||||
(recur))))))
|
||||
(go-loop []
|
||||
(let [v (<! from)]
|
||||
(if (nil? v)
|
||||
(close! jobs)
|
||||
(let [p (chan 1)]
|
||||
(>! jobs [v p])
|
||||
(>! results p)
|
||||
(recur)))))
|
||||
(go-loop []
|
||||
(let [p (<! results)]
|
||||
(if (nil? p)
|
||||
(when close? (close! to))
|
||||
(let [res (<! p)]
|
||||
(loop []
|
||||
(let [v (<! res)]
|
||||
(when (and (not (nil? v)) (>! to v))
|
||||
(recur))))
|
||||
(recur))))))))
|
||||
|
||||
(defn pipeline-async
|
||||
"Takes elements from the from channel and supplies them to the to
|
||||
channel, subject to the async function af, with parallelism n. af
|
||||
must be a function of two arguments, the first an input value and
|
||||
the second a channel on which to place the result(s). af must close!
|
||||
the channel before returning. The presumption is that af will
|
||||
return immediately, having launched some asynchronous operation
|
||||
whose completion/callback will manipulate the result channel. Outputs
|
||||
will be returned in order relative to the inputs. By default, the to
|
||||
channel will be closed when the from channel closes, but can be
|
||||
determined by the close? parameter. Will stop consuming the from
|
||||
channel if the to channel closes."
|
||||
([n to af from] (pipeline-async n to af from true))
|
||||
([n to af from close?] (pipeline* n to af from close? nil :async)))
|
||||
|
||||
(defn pipeline
|
||||
"Takes elements from the from channel and supplies them to the to
|
||||
channel, subject to the transducer xf, with parallelism n. Because
|
||||
it is parallel, the transducer will be applied independently to each
|
||||
element, not across elements, and may produce zero or more outputs
|
||||
per input. Outputs will be returned in order relative to the
|
||||
inputs. By default, the to channel will be closed when the from
|
||||
channel closes, but can be determined by the close? parameter. Will
|
||||
stop consuming the from channel if the to channel closes.
|
||||
|
||||
Note this is supplied for API compatibility with the Clojure version.
|
||||
Values of N > 1 will not result in actual concurrency in a
|
||||
single-threaded runtime."
|
||||
([n to xf from] (pipeline n to xf from true))
|
||||
([n to xf from close?] (pipeline n to xf from close? nil))
|
||||
([n to xf from close? ex-handler] (pipeline* n to xf from close? ex-handler :compute)))
|
||||
|
||||
(defn split
|
||||
"Takes a predicate and a source channel and returns a vector of two
|
||||
channels, the first of which will contain the values for which the
|
||||
predicate returned true, the second those for which it returned
|
||||
false.
|
||||
|
||||
The out channels will be unbuffered by default, or two buf-or-ns can
|
||||
be supplied. The channels will close after the source channel has
|
||||
closed."
|
||||
([p ch] (split p ch nil nil))
|
||||
([p ch t-buf-or-n f-buf-or-n]
|
||||
(let [tc (chan t-buf-or-n)
|
||||
fc (chan f-buf-or-n)]
|
||||
(go-loop []
|
||||
(let [v (<! ch)]
|
||||
(if (nil? v)
|
||||
(do (close! tc) (close! fc))
|
||||
(when (>! (if (p v) tc fc) v)
|
||||
(recur)))))
|
||||
[tc fc])))
|
||||
|
||||
(defn reduce
|
||||
"f should be a function of 2 arguments. Returns a channel containing
|
||||
the single result of applying f to init and the first item from the
|
||||
channel, then applying f to that result and the 2nd item, etc. If
|
||||
the channel closes without yielding items, returns init and f is not
|
||||
called. ch must close before reduce produces a result."
|
||||
[f init ch]
|
||||
(go-loop [ret init]
|
||||
(let [v (<! ch)]
|
||||
(if (nil? v)
|
||||
ret
|
||||
(let [ret' (f ret v)]
|
||||
(if (reduced? ret')
|
||||
@ret'
|
||||
(recur ret')))))))
|
||||
|
||||
(defn transduce
|
||||
"async/reduces a channel with a transformation (xform f).
|
||||
Returns a channel containing the result. ch must close before
|
||||
transduce produces a result."
|
||||
[xform f init ch]
|
||||
(let [f (xform f)]
|
||||
(go
|
||||
(let [ret (<! (reduce f init ch))]
|
||||
(f ret)))))
|
||||
|
||||
(defn onto-chan
|
||||
"Puts the contents of coll into the supplied channel.
|
||||
|
||||
By default the channel will be closed after the items are copied,
|
||||
but can be determined by the close? parameter.
|
||||
|
||||
Returns a channel which will close after the items are copied."
|
||||
([ch coll] (onto-chan ch coll true))
|
||||
([ch coll close?]
|
||||
(go-loop [vs (seq coll)]
|
||||
(if (and vs (>! ch (first vs)))
|
||||
(recur (next vs))
|
||||
(when close?
|
||||
(close! ch))))))
|
||||
|
||||
|
||||
(defn to-chan
|
||||
"Creates and returns a channel which contains the contents of coll,
|
||||
closing when exhausted."
|
||||
[coll]
|
||||
(let [ch (chan (bounded-count 100 coll))]
|
||||
(onto-chan ch coll)
|
||||
ch))
|
||||
|
||||
|
||||
(defprotocol Mux
|
||||
(muxch* [_]))
|
||||
|
||||
(defprotocol Mult
|
||||
(tap* [m ch close?])
|
||||
(untap* [m ch])
|
||||
(untap-all* [m]))
|
||||
|
||||
(defn mult
|
||||
"Creates and returns a mult(iple) of the supplied channel. Channels
|
||||
containing copies of the channel can be created with 'tap', and
|
||||
detached with 'untap'.
|
||||
|
||||
Each item is distributed to all taps in parallel and synchronously,
|
||||
i.e. each tap must accept before the next item is distributed. Use
|
||||
buffering/windowing to prevent slow taps from holding up the mult.
|
||||
|
||||
Items received when there are no taps get dropped.
|
||||
|
||||
If a tap puts to a closed channel, it will be removed from the mult."
|
||||
[ch]
|
||||
(let [cs (atom {}) ;;ch->close?
|
||||
m (reify
|
||||
Mux
|
||||
(muxch* [_] ch)
|
||||
|
||||
Mult
|
||||
(tap* [_ ch close?] (swap! cs assoc ch close?) nil)
|
||||
(untap* [_ ch] (swap! cs dissoc ch) nil)
|
||||
(untap-all* [_] (reset! cs {}) nil))
|
||||
dchan (chan 1)
|
||||
dctr (atom nil)
|
||||
done (fn [_] (when (zero? (swap! dctr dec))
|
||||
(put! dchan true)))]
|
||||
(go-loop []
|
||||
(let [val (<! ch)]
|
||||
(if (nil? val)
|
||||
(doseq [[c close?] @cs]
|
||||
(when close? (close! c)))
|
||||
(let [chs (keys @cs)]
|
||||
(reset! dctr (count chs))
|
||||
(doseq [c chs]
|
||||
(when-not (put! c val done)
|
||||
(done nil)
|
||||
(untap* m c)))
|
||||
;;wait for all
|
||||
(when (seq chs)
|
||||
(<! dchan))
|
||||
(recur)))))
|
||||
m))
|
||||
|
||||
(defn tap
|
||||
"Copies the mult source onto the supplied channel.
|
||||
|
||||
By default the channel will be closed when the source closes,
|
||||
but can be determined by the close? parameter."
|
||||
([mult ch] (tap mult ch true))
|
||||
([mult ch close?] (tap* mult ch close?) ch))
|
||||
|
||||
(defn untap
|
||||
"Disconnects a target channel from a mult"
|
||||
[mult ch]
|
||||
(untap* mult ch))
|
||||
|
||||
(defn untap-all
|
||||
"Disconnects all target channels from a mult"
|
||||
[mult] (untap-all* mult))
|
||||
|
||||
(defprotocol Mix
|
||||
(admix* [m ch])
|
||||
(unmix* [m ch])
|
||||
(unmix-all* [m])
|
||||
(toggle* [m state-map])
|
||||
(solo-mode* [m mode]))
|
||||
|
||||
(defn ioc-alts! [state cont-block ports & {:as opts}]
|
||||
(ioc/aset-all! state helpers/STATE-IDX cont-block)
|
||||
(when-let [cb (cljs.core.async/do-alts
|
||||
(fn [val]
|
||||
(ioc/aset-all! state helpers/VALUE-IDX val)
|
||||
(helpers/run-state-machine-wrapped state))
|
||||
ports
|
||||
opts)]
|
||||
(ioc/aset-all! state helpers/VALUE-IDX @cb)
|
||||
:recur))
|
||||
|
||||
(defn mix
|
||||
"Creates and returns a mix of one or more input channels which will
|
||||
be put on the supplied out channel. Input sources can be added to
|
||||
the mix with 'admix', and removed with 'unmix'. A mix supports
|
||||
soloing, muting and pausing multiple inputs atomically using
|
||||
'toggle', and can solo using either muting or pausing as determined
|
||||
by 'solo-mode'.
|
||||
|
||||
Each channel can have zero or more boolean modes set via 'toggle':
|
||||
|
||||
:solo - when true, only this (ond other soloed) channel(s) will appear
|
||||
in the mix output channel. :mute and :pause states of soloed
|
||||
channels are ignored. If solo-mode is :mute, non-soloed
|
||||
channels are muted, if :pause, non-soloed channels are
|
||||
paused.
|
||||
|
||||
:mute - muted channels will have their contents consumed but not included in the mix
|
||||
:pause - paused channels will not have their contents consumed (and thus also not included in the mix)
|
||||
"
|
||||
[out]
|
||||
(let [cs (atom {}) ;;ch->attrs-map
|
||||
solo-modes #{:mute :pause}
|
||||
attrs (conj solo-modes :solo)
|
||||
solo-mode (atom :mute)
|
||||
change (chan)
|
||||
changed #(put! change true)
|
||||
pick (fn [attr chs]
|
||||
(reduce-kv
|
||||
(fn [ret c v]
|
||||
(if (attr v)
|
||||
(conj ret c)
|
||||
ret))
|
||||
#{} chs))
|
||||
calc-state (fn []
|
||||
(let [chs @cs
|
||||
mode @solo-mode
|
||||
solos (pick :solo chs)
|
||||
pauses (pick :pause chs)]
|
||||
{:solos solos
|
||||
:mutes (pick :mute chs)
|
||||
:reads (conj
|
||||
(if (and (= mode :pause) (not (empty? solos)))
|
||||
(vec solos)
|
||||
(vec (remove pauses (keys chs))))
|
||||
change)}))
|
||||
m (reify
|
||||
Mux
|
||||
(muxch* [_] out)
|
||||
Mix
|
||||
(admix* [_ ch] (swap! cs assoc ch {}) (changed))
|
||||
(unmix* [_ ch] (swap! cs dissoc ch) (changed))
|
||||
(unmix-all* [_] (reset! cs {}) (changed))
|
||||
(toggle* [_ state-map] (swap! cs (partial merge-with cljs.core/merge) state-map) (changed))
|
||||
(solo-mode* [_ mode]
|
||||
(assert (solo-modes mode) (str "mode must be one of: " solo-modes))
|
||||
(reset! solo-mode mode)
|
||||
(changed)))]
|
||||
(go-loop [{:keys [solos mutes reads] :as state} (calc-state)]
|
||||
(let [[v c] (alts! reads)]
|
||||
(if (or (nil? v) (= c change))
|
||||
(do (when (nil? v)
|
||||
(swap! cs dissoc c))
|
||||
(recur (calc-state)))
|
||||
(if (or (solos c)
|
||||
(and (empty? solos) (not (mutes c))))
|
||||
(when (>! out v)
|
||||
(recur state))
|
||||
(recur state)))))
|
||||
m))
|
||||
|
||||
(defn admix
|
||||
"Adds ch as an input to the mix"
|
||||
[mix ch]
|
||||
(admix* mix ch))
|
||||
|
||||
(defn unmix
|
||||
"Removes ch as an input to the mix"
|
||||
[mix ch]
|
||||
(unmix* mix ch))
|
||||
|
||||
(defn unmix-all
|
||||
"removes all inputs from the mix"
|
||||
[mix]
|
||||
(unmix-all* mix))
|
||||
|
||||
(defn toggle
|
||||
"Atomically sets the state(s) of one or more channels in a mix. The
|
||||
state map is a map of channels -> channel-state-map. A
|
||||
channel-state-map is a map of attrs -> boolean, where attr is one or
|
||||
more of :mute, :pause or :solo. Any states supplied are merged with
|
||||
the current state.
|
||||
|
||||
Note that channels can be added to a mix via toggle, which can be
|
||||
used to add channels in a particular (e.g. paused) state."
|
||||
[mix state-map]
|
||||
(toggle* mix state-map))
|
||||
|
||||
(defn solo-mode
|
||||
"Sets the solo mode of the mix. mode must be one of :mute or :pause"
|
||||
[mix mode]
|
||||
(solo-mode* mix mode))
|
||||
|
||||
|
||||
(defprotocol Pub
|
||||
(sub* [p v ch close?])
|
||||
(unsub* [p v ch])
|
||||
(unsub-all* [p] [p v]))
|
||||
|
||||
(defn pub
|
||||
"Creates and returns a pub(lication) of the supplied channel,
|
||||
partitioned into topics by the topic-fn. topic-fn will be applied to
|
||||
each value on the channel and the result will determine the 'topic'
|
||||
on which that value will be put. Channels can be subscribed to
|
||||
receive copies of topics using 'sub', and unsubscribed using
|
||||
'unsub'. Each topic will be handled by an internal mult on a
|
||||
dedicated channel. By default these internal channels are
|
||||
unbuffered, but a buf-fn can be supplied which, given a topic,
|
||||
creates a buffer with desired properties.
|
||||
|
||||
Each item is distributed to all subs in parallel and synchronously,
|
||||
i.e. each sub must accept before the next item is distributed. Use
|
||||
buffering/windowing to prevent slow subs from holding up the pub.
|
||||
|
||||
Items received when there are no matching subs get dropped.
|
||||
|
||||
Note that if buf-fns are used then each topic is handled
|
||||
asynchronously, i.e. if a channel is subscribed to more than one
|
||||
topic it should not expect them to be interleaved identically with
|
||||
the source."
|
||||
([ch topic-fn] (pub ch topic-fn (constantly nil)))
|
||||
([ch topic-fn buf-fn]
|
||||
(let [mults (atom {}) ;;topic->mult
|
||||
ensure-mult (fn [topic]
|
||||
(or (get @mults topic)
|
||||
(get (swap! mults
|
||||
#(if (% topic) % (assoc % topic (mult (chan (buf-fn topic))))))
|
||||
topic)))
|
||||
p (reify
|
||||
Mux
|
||||
(muxch* [_] ch)
|
||||
|
||||
Pub
|
||||
(sub* [p topic ch close?]
|
||||
(let [m (ensure-mult topic)]
|
||||
(tap m ch close?)))
|
||||
(unsub* [p topic ch]
|
||||
(when-let [m (get @mults topic)]
|
||||
(untap m ch)))
|
||||
(unsub-all* [_] (reset! mults {}))
|
||||
(unsub-all* [_ topic] (swap! mults dissoc topic)))]
|
||||
(go-loop []
|
||||
(let [val (<! ch)]
|
||||
(if (nil? val)
|
||||
(doseq [m (vals @mults)]
|
||||
(close! (muxch* m)))
|
||||
(let [topic (topic-fn val)
|
||||
m (get @mults topic)]
|
||||
(when m
|
||||
(when-not (>! (muxch* m) val)
|
||||
(swap! mults dissoc topic)))
|
||||
(recur)))))
|
||||
p)))
|
||||
|
||||
(defn sub
|
||||
"Subscribes a channel to a topic of a pub.
|
||||
|
||||
By default the channel will be closed when the source closes,
|
||||
but can be determined by the close? parameter."
|
||||
([p topic ch] (sub p topic ch true))
|
||||
([p topic ch close?] (sub* p topic ch close?)))
|
||||
|
||||
(defn unsub
|
||||
"Unsubscribes a channel from a topic of a pub"
|
||||
[p topic ch]
|
||||
(unsub* p topic ch))
|
||||
|
||||
(defn unsub-all
|
||||
"Unsubscribes all channels from a pub, or a topic of a pub"
|
||||
([p] (unsub-all* p))
|
||||
([p topic] (unsub-all* p topic)))
|
||||
|
||||
|
||||
;;;;
|
||||
|
||||
(defn map
|
||||
"Takes a function and a collection of source channels, and returns a
|
||||
channel which contains the values produced by applying f to the set
|
||||
of first items taken from each source channel, followed by applying
|
||||
f to the set of second items from each channel, until any one of the
|
||||
channels is closed, at which point the output channel will be
|
||||
closed. The returned channel will be unbuffered by default, or a
|
||||
buf-or-n can be supplied"
|
||||
([f chs] (map f chs nil))
|
||||
([f chs buf-or-n]
|
||||
(let [chs (vec chs)
|
||||
out (chan buf-or-n)
|
||||
cnt (count chs)
|
||||
rets (object-array cnt)
|
||||
dchan (chan 1)
|
||||
dctr (atom nil)
|
||||
done (mapv (fn [i]
|
||||
(fn [ret]
|
||||
(aset rets i ret)
|
||||
(when (zero? (swap! dctr dec))
|
||||
(put! dchan (.slice rets 0)))))
|
||||
(range cnt))]
|
||||
(go-loop []
|
||||
(reset! dctr cnt)
|
||||
(dotimes [i cnt]
|
||||
(try
|
||||
(take! (chs i) (done i))
|
||||
(catch js/Object e
|
||||
(swap! dctr dec))))
|
||||
(let [rets (<! dchan)]
|
||||
(if (some nil? rets)
|
||||
(close! out)
|
||||
(do (>! out (apply f rets))
|
||||
(recur)))))
|
||||
out)))
|
||||
|
||||
(defn merge
|
||||
"Takes a collection of source channels and returns a channel which
|
||||
contains all values taken from them. The returned channel will be
|
||||
unbuffered by default, or a buf-or-n can be supplied. The channel
|
||||
will close after all the source channels have closed."
|
||||
([chs] (merge chs nil))
|
||||
([chs buf-or-n]
|
||||
(let [out (chan buf-or-n)]
|
||||
(go-loop [cs (vec chs)]
|
||||
(if (pos? (count cs))
|
||||
(let [[v c] (alts! cs)]
|
||||
(if (nil? v)
|
||||
(recur (filterv #(not= c %) cs))
|
||||
(do (>! out v)
|
||||
(recur cs))))
|
||||
(close! out)))
|
||||
out)))
|
||||
|
||||
(defn into
|
||||
"Returns a channel containing the single (collection) result of the
|
||||
items taken from the channel conjoined to the supplied
|
||||
collection. ch must close before into produces a result."
|
||||
[coll ch]
|
||||
(reduce conj coll ch))
|
||||
|
||||
(defn take
|
||||
"Returns a channel that will return, at most, n items from ch. After n items
|
||||
have been returned, or ch has been closed, the return chanel will close.
|
||||
|
||||
The output channel is unbuffered by default, unless buf-or-n is given."
|
||||
([n ch]
|
||||
(take n ch nil))
|
||||
([n ch buf-or-n]
|
||||
(let [out (chan buf-or-n)]
|
||||
(go (loop [x 0]
|
||||
(when (< x n)
|
||||
(let [v (<! ch)]
|
||||
(when (not (nil? v))
|
||||
(>! out v)
|
||||
(recur (inc x))))))
|
||||
(close! out))
|
||||
out)))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; deprecated - do not use ;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(defn map<
|
||||
"Deprecated - this function will be removed. Use transducer instead"
|
||||
[f ch]
|
||||
(reify
|
||||
impl/Channel
|
||||
(close! [_] (impl/close! ch))
|
||||
(closed? [_] (impl/closed? ch))
|
||||
|
||||
impl/ReadPort
|
||||
(take! [_ fn1]
|
||||
(let [ret
|
||||
(impl/take! ch
|
||||
(reify
|
||||
impl/Handler
|
||||
(active? [_] (impl/active? fn1))
|
||||
(blockable? [_] true)
|
||||
#_(lock-id [_] (impl/lock-id fn1))
|
||||
(commit [_]
|
||||
(let [f1 (impl/commit fn1)]
|
||||
#(f1 (if (nil? %) nil (f %)))))))]
|
||||
(if (and ret (not (nil? @ret)))
|
||||
(channels/box (f @ret))
|
||||
ret)))
|
||||
|
||||
impl/WritePort
|
||||
(put! [_ val fn1] (impl/put! ch val fn1))))
|
||||
|
||||
(defn map>
|
||||
"Deprecated - this function will be removed. Use transducer instead"
|
||||
[f ch]
|
||||
(reify
|
||||
impl/Channel
|
||||
(close! [_] (impl/close! ch))
|
||||
|
||||
impl/ReadPort
|
||||
(take! [_ fn1] (impl/take! ch fn1))
|
||||
|
||||
impl/WritePort
|
||||
(put! [_ val fn1]
|
||||
(impl/put! ch (f val) fn1))))
|
||||
|
||||
(defn filter>
|
||||
"Deprecated - this function will be removed. Use transducer instead"
|
||||
[p ch]
|
||||
(reify
|
||||
impl/Channel
|
||||
(close! [_] (impl/close! ch))
|
||||
(closed? [_] (impl/closed? ch))
|
||||
|
||||
impl/ReadPort
|
||||
(take! [_ fn1] (impl/take! ch fn1))
|
||||
|
||||
impl/WritePort
|
||||
(put! [_ val fn1]
|
||||
(if (p val)
|
||||
(impl/put! ch val fn1)
|
||||
(channels/box (not (impl/closed? ch)))))))
|
||||
|
||||
(defn remove>
|
||||
"Deprecated - this function will be removed. Use transducer instead"
|
||||
[p ch]
|
||||
(filter> (complement p) ch))
|
||||
|
||||
(defn filter<
|
||||
"Deprecated - this function will be removed. Use transducer instead"
|
||||
([p ch] (filter< p ch nil))
|
||||
([p ch buf-or-n]
|
||||
(let [out (chan buf-or-n)]
|
||||
(go-loop []
|
||||
(let [val (<! ch)]
|
||||
(if (nil? val)
|
||||
(close! out)
|
||||
(do (when (p val)
|
||||
(>! out val))
|
||||
(recur)))))
|
||||
out)))
|
||||
|
||||
(defn remove<
|
||||
"Deprecated - this function will be removed. Use transducer instead"
|
||||
([p ch] (remove< p ch nil))
|
||||
([p ch buf-or-n] (filter< (complement p) ch buf-or-n)))
|
||||
|
||||
(defn- mapcat* [f in out]
|
||||
(go-loop []
|
||||
(let [val (<! in)]
|
||||
(if (nil? val)
|
||||
(close! out)
|
||||
(do (doseq [v (f val)]
|
||||
(>! out v))
|
||||
(when-not (impl/closed? out)
|
||||
(recur)))))))
|
||||
|
||||
(defn mapcat<
|
||||
"Deprecated - this function will be removed. Use transducer instead"
|
||||
([f in] (mapcat< f in nil))
|
||||
([f in buf-or-n]
|
||||
(let [out (chan buf-or-n)]
|
||||
(mapcat* f in out)
|
||||
out)))
|
||||
|
||||
(defn mapcat>
|
||||
"Deprecated - this function will be removed. Use transducer instead"
|
||||
([f out] (mapcat> f out nil))
|
||||
([f out buf-or-n]
|
||||
(let [in (chan buf-or-n)]
|
||||
(mapcat* f in out)
|
||||
in)))
|
||||
|
||||
(defn unique
|
||||
"Deprecated - this function will be removed. Use transducer instead"
|
||||
([ch]
|
||||
(unique ch nil))
|
||||
([ch buf-or-n]
|
||||
(let [out (chan buf-or-n)]
|
||||
(go (loop [last nil]
|
||||
(let [v (<! ch)]
|
||||
(when (not (nil? v))
|
||||
(if (= v last)
|
||||
(recur last)
|
||||
(do (>! out v)
|
||||
(recur v))))))
|
||||
(close! out))
|
||||
out)))
|
||||
|
||||
(defn partition
|
||||
"Deprecated - this function will be removed. Use transducer instead"
|
||||
([n ch]
|
||||
(partition n ch nil))
|
||||
([n ch buf-or-n]
|
||||
(let [out (chan buf-or-n)]
|
||||
(go (loop [arr (make-array n)
|
||||
idx 0]
|
||||
(let [v (<! ch)]
|
||||
(if (not (nil? v))
|
||||
(do (aset ^objects arr idx v)
|
||||
(let [new-idx (inc idx)]
|
||||
(if (< new-idx n)
|
||||
(recur arr new-idx)
|
||||
(do (>! out (vec arr))
|
||||
(recur (make-array n) 0)))))
|
||||
(do (when (> idx 0)
|
||||
(>! out (vec arr)))
|
||||
(close! out))))))
|
||||
out)))
|
||||
|
||||
|
||||
(defn partition-by
|
||||
"Deprecated - this function will be removed. Use transducer instead"
|
||||
([f ch]
|
||||
(partition-by f ch nil))
|
||||
([f ch buf-or-n]
|
||||
(let [out (chan buf-or-n)]
|
||||
(go (loop [lst (make-array 0)
|
||||
last ::nothing]
|
||||
(let [v (<! ch)]
|
||||
(if (not (nil? v))
|
||||
(let [new-itm (f v)]
|
||||
(if (or (= new-itm last)
|
||||
(keyword-identical? last ::nothing))
|
||||
(do (.push lst v)
|
||||
(recur lst new-itm))
|
||||
(do (>! out (vec lst))
|
||||
(let [new-lst (make-array 0)]
|
||||
(.push new-lst v)
|
||||
(recur new-lst new-itm)))))
|
||||
(do (when (> (alength lst) 0)
|
||||
(>! out (vec lst)))
|
||||
(close! out))))))
|
||||
out)))
|
||||
File diff suppressed because one or more lines are too long
9043
resources/public/target/cljsbuild-compiler-1/cljs/core/async.js
Normal file
9043
resources/public/target/cljsbuild-compiler-1/cljs/core/async.js
Normal file
File diff suppressed because it is too large
Load diff
File diff suppressed because one or more lines are too long
|
|
@ -0,0 +1,159 @@
|
|||
;; Copyright (c) Rich Hickey and contributors. All rights reserved.
|
||||
;; The use and distribution terms for this software are covered by the
|
||||
;; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
|
||||
;; which can be found in the file epl-v10.html at the root of this distribution.
|
||||
;; By using this software in any fashion, you are agreeing to be bound by
|
||||
;; the terms of this license.
|
||||
;; You must not remove this notice, or any other, from this software.
|
||||
|
||||
(ns cljs.core.async.impl.buffers
|
||||
(:require [cljs.core.async.impl.protocols :as impl]))
|
||||
|
||||
;; -----------------------------------------------------------------------------
|
||||
;; DO NOT USE, this is internal buffer representation
|
||||
|
||||
(defn acopy [src src-start dest dest-start len]
|
||||
(loop [cnt 0]
|
||||
(when (< cnt len)
|
||||
(aset dest
|
||||
(+ dest-start cnt)
|
||||
(aget src (+ src-start cnt)))
|
||||
(recur (inc cnt)))))
|
||||
|
||||
(deftype RingBuffer [^:mutable head ^:mutable tail ^:mutable length ^:mutable arr]
|
||||
Object
|
||||
(pop [_]
|
||||
(when-not (zero? length)
|
||||
(let [x (aget arr tail)]
|
||||
(aset arr tail nil)
|
||||
(set! tail (js-mod (inc tail) (alength arr)))
|
||||
(set! length (dec length))
|
||||
x)))
|
||||
|
||||
(unshift [_ x]
|
||||
(aset arr head x)
|
||||
(set! head (js-mod (inc head) (alength arr)))
|
||||
(set! length (inc length))
|
||||
nil)
|
||||
|
||||
(unbounded-unshift [this x]
|
||||
(if (== (inc length) (alength arr))
|
||||
(.resize this))
|
||||
(.unshift this x))
|
||||
|
||||
;; Doubles the size of the buffer while retaining all the existing values
|
||||
(resize
|
||||
[_]
|
||||
(let [new-arr-size (* (alength arr) 2)
|
||||
new-arr (make-array new-arr-size)]
|
||||
(cond
|
||||
(< tail head)
|
||||
(do (acopy arr tail new-arr 0 length)
|
||||
(set! tail 0)
|
||||
(set! head length)
|
||||
(set! arr new-arr))
|
||||
|
||||
(> tail head)
|
||||
(do (acopy arr tail new-arr 0 (- (alength arr) tail))
|
||||
(acopy arr 0 new-arr (- (alength arr) tail) head)
|
||||
(set! tail 0)
|
||||
(set! head length)
|
||||
(set! arr new-arr))
|
||||
|
||||
(== tail head)
|
||||
(do (set! tail 0)
|
||||
(set! head 0)
|
||||
(set! arr new-arr)))))
|
||||
|
||||
(cleanup [this keep?]
|
||||
(dotimes [x length]
|
||||
(let [v (.pop this)]
|
||||
(when ^boolean (keep? v)
|
||||
(.unshift this v))))))
|
||||
|
||||
(defn ring-buffer [n]
|
||||
(assert (> n 0) "Can't create a ring buffer of size 0")
|
||||
(RingBuffer. 0 0 0 (make-array n)))
|
||||
|
||||
;; -----------------------------------------------------------------------------
|
||||
|
||||
(deftype FixedBuffer [buf n]
|
||||
impl/Buffer
|
||||
(full? [this]
|
||||
(== (.-length buf) n))
|
||||
(remove! [this]
|
||||
(.pop buf))
|
||||
(add!* [this itm]
|
||||
(.unbounded-unshift buf itm)
|
||||
this)
|
||||
(close-buf! [this])
|
||||
cljs.core/ICounted
|
||||
(-count [this]
|
||||
(.-length buf)))
|
||||
|
||||
(defn fixed-buffer [n]
|
||||
(FixedBuffer. (ring-buffer n) n))
|
||||
|
||||
(deftype DroppingBuffer [buf n]
|
||||
impl/UnblockingBuffer
|
||||
impl/Buffer
|
||||
(full? [this]
|
||||
false)
|
||||
(remove! [this]
|
||||
(.pop buf))
|
||||
(add!* [this itm]
|
||||
(when-not (== (.-length buf) n)
|
||||
(.unshift buf itm))
|
||||
this)
|
||||
(close-buf! [this])
|
||||
cljs.core/ICounted
|
||||
(-count [this]
|
||||
(.-length buf)))
|
||||
|
||||
(defn dropping-buffer [n]
|
||||
(DroppingBuffer. (ring-buffer n) n))
|
||||
|
||||
(deftype SlidingBuffer [buf n]
|
||||
impl/UnblockingBuffer
|
||||
impl/Buffer
|
||||
(full? [this]
|
||||
false)
|
||||
(remove! [this]
|
||||
(.pop buf))
|
||||
(add!* [this itm]
|
||||
(when (== (.-length buf) n)
|
||||
(impl/remove! this))
|
||||
(.unshift buf itm)
|
||||
this)
|
||||
(close-buf! [this])
|
||||
cljs.core/ICounted
|
||||
(-count [this]
|
||||
(.-length buf)))
|
||||
|
||||
(defn sliding-buffer [n]
|
||||
(SlidingBuffer. (ring-buffer n) n))
|
||||
|
||||
(defonce ^:private NO-VAL (js/Object.))
|
||||
(defn- undelivered? [val]
|
||||
(identical? NO-VAL val))
|
||||
|
||||
(deftype PromiseBuffer [^:mutable val]
|
||||
impl/UnblockingBuffer
|
||||
impl/Buffer
|
||||
(full? [_]
|
||||
false)
|
||||
(remove! [_]
|
||||
val)
|
||||
(add!* [this itm]
|
||||
(when (undelivered? val)
|
||||
(set! val itm))
|
||||
this)
|
||||
(close-buf! [_]
|
||||
(when (undelivered? val)
|
||||
(set! val nil)))
|
||||
cljs.core/ICounted
|
||||
(-count [_]
|
||||
(if (undelivered? val) 0 1)))
|
||||
|
||||
(defn promise-buffer []
|
||||
(PromiseBuffer. NO-VAL))
|
||||
File diff suppressed because one or more lines are too long
|
|
@ -0,0 +1,466 @@
|
|||
// Compiled by ClojureScript 1.10.520 {}
|
||||
goog.provide('cljs.core.async.impl.buffers');
|
||||
goog.require('cljs.core');
|
||||
goog.require('cljs.core.async.impl.protocols');
|
||||
cljs.core.async.impl.buffers.acopy = (function cljs$core$async$impl$buffers$acopy(src,src_start,dest,dest_start,len){
|
||||
var cnt = (0);
|
||||
while(true){
|
||||
if((cnt < len)){
|
||||
(dest[(dest_start + cnt)] = (src[(src_start + cnt)]));
|
||||
|
||||
var G__21530 = (cnt + (1));
|
||||
cnt = G__21530;
|
||||
continue;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @implements {cljs.core.async.impl.buffers.Object}
|
||||
*/
|
||||
cljs.core.async.impl.buffers.RingBuffer = (function (head,tail,length,arr){
|
||||
this.head = head;
|
||||
this.tail = tail;
|
||||
this.length = length;
|
||||
this.arr = arr;
|
||||
});
|
||||
cljs.core.async.impl.buffers.RingBuffer.prototype.pop = (function (){
|
||||
var self__ = this;
|
||||
var _ = this;
|
||||
if((self__.length === (0))){
|
||||
return null;
|
||||
} else {
|
||||
var x = (self__.arr[self__.tail]);
|
||||
(self__.arr[self__.tail] = null);
|
||||
|
||||
self__.tail = ((self__.tail + (1)) % self__.arr.length);
|
||||
|
||||
self__.length = (self__.length - (1));
|
||||
|
||||
return x;
|
||||
}
|
||||
});
|
||||
|
||||
cljs.core.async.impl.buffers.RingBuffer.prototype.unshift = (function (x){
|
||||
var self__ = this;
|
||||
var _ = this;
|
||||
(self__.arr[self__.head] = x);
|
||||
|
||||
self__.head = ((self__.head + (1)) % self__.arr.length);
|
||||
|
||||
self__.length = (self__.length + (1));
|
||||
|
||||
return null;
|
||||
});
|
||||
|
||||
cljs.core.async.impl.buffers.RingBuffer.prototype.unbounded_unshift = (function (x){
|
||||
var self__ = this;
|
||||
var this$ = this;
|
||||
if(((self__.length + (1)) === self__.arr.length)){
|
||||
this$.resize();
|
||||
} else {
|
||||
}
|
||||
|
||||
return this$.unshift(x);
|
||||
});
|
||||
|
||||
cljs.core.async.impl.buffers.RingBuffer.prototype.resize = (function (){
|
||||
var self__ = this;
|
||||
var _ = this;
|
||||
var new_arr_size = (self__.arr.length * (2));
|
||||
var new_arr = (new Array(new_arr_size));
|
||||
if((self__.tail < self__.head)){
|
||||
cljs.core.async.impl.buffers.acopy.call(null,self__.arr,self__.tail,new_arr,(0),self__.length);
|
||||
|
||||
self__.tail = (0);
|
||||
|
||||
self__.head = self__.length;
|
||||
|
||||
return self__.arr = new_arr;
|
||||
} else {
|
||||
if((self__.tail > self__.head)){
|
||||
cljs.core.async.impl.buffers.acopy.call(null,self__.arr,self__.tail,new_arr,(0),(self__.arr.length - self__.tail));
|
||||
|
||||
cljs.core.async.impl.buffers.acopy.call(null,self__.arr,(0),new_arr,(self__.arr.length - self__.tail),self__.head);
|
||||
|
||||
self__.tail = (0);
|
||||
|
||||
self__.head = self__.length;
|
||||
|
||||
return self__.arr = new_arr;
|
||||
} else {
|
||||
if((self__.tail === self__.head)){
|
||||
self__.tail = (0);
|
||||
|
||||
self__.head = (0);
|
||||
|
||||
return self__.arr = new_arr;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
cljs.core.async.impl.buffers.RingBuffer.prototype.cleanup = (function (keep_QMARK_){
|
||||
var self__ = this;
|
||||
var this$ = this;
|
||||
var n__4607__auto__ = self__.length;
|
||||
var x = (0);
|
||||
while(true){
|
||||
if((x < n__4607__auto__)){
|
||||
var v_21531 = this$.pop();
|
||||
if(keep_QMARK_.call(null,v_21531)){
|
||||
this$.unshift(v_21531);
|
||||
} else {
|
||||
}
|
||||
|
||||
var G__21532 = (x + (1));
|
||||
x = G__21532;
|
||||
continue;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
cljs.core.async.impl.buffers.RingBuffer.getBasis = (function (){
|
||||
return new cljs.core.PersistentVector(null, 4, 5, cljs.core.PersistentVector.EMPTY_NODE, [cljs.core.with_meta(new cljs.core.Symbol(null,"head","head",869147608,null),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"mutable","mutable",875778266),true], null)),cljs.core.with_meta(new cljs.core.Symbol(null,"tail","tail",494507963,null),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"mutable","mutable",875778266),true], null)),cljs.core.with_meta(new cljs.core.Symbol(null,"length","length",-2065447907,null),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"mutable","mutable",875778266),true], null)),cljs.core.with_meta(new cljs.core.Symbol(null,"arr","arr",2115492975,null),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"mutable","mutable",875778266),true], null))], null);
|
||||
});
|
||||
|
||||
cljs.core.async.impl.buffers.RingBuffer.cljs$lang$type = true;
|
||||
|
||||
cljs.core.async.impl.buffers.RingBuffer.cljs$lang$ctorStr = "cljs.core.async.impl.buffers/RingBuffer";
|
||||
|
||||
cljs.core.async.impl.buffers.RingBuffer.cljs$lang$ctorPrWriter = (function (this__4374__auto__,writer__4375__auto__,opt__4376__auto__){
|
||||
return cljs.core._write.call(null,writer__4375__auto__,"cljs.core.async.impl.buffers/RingBuffer");
|
||||
});
|
||||
|
||||
/**
|
||||
* Positional factory function for cljs.core.async.impl.buffers/RingBuffer.
|
||||
*/
|
||||
cljs.core.async.impl.buffers.__GT_RingBuffer = (function cljs$core$async$impl$buffers$__GT_RingBuffer(head,tail,length,arr){
|
||||
return (new cljs.core.async.impl.buffers.RingBuffer(head,tail,length,arr));
|
||||
});
|
||||
|
||||
cljs.core.async.impl.buffers.ring_buffer = (function cljs$core$async$impl$buffers$ring_buffer(n){
|
||||
if((n > (0))){
|
||||
} else {
|
||||
throw (new Error(["Assert failed: ","Can't create a ring buffer of size 0","\n","(> n 0)"].join('')));
|
||||
}
|
||||
|
||||
return (new cljs.core.async.impl.buffers.RingBuffer((0),(0),(0),(new Array(n))));
|
||||
});
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @implements {cljs.core.ICounted}
|
||||
* @implements {cljs.core.async.impl.protocols.Buffer}
|
||||
*/
|
||||
cljs.core.async.impl.buffers.FixedBuffer = (function (buf,n){
|
||||
this.buf = buf;
|
||||
this.n = n;
|
||||
this.cljs$lang$protocol_mask$partition0$ = 2;
|
||||
this.cljs$lang$protocol_mask$partition1$ = 0;
|
||||
});
|
||||
cljs.core.async.impl.buffers.FixedBuffer.prototype.cljs$core$async$impl$protocols$Buffer$ = cljs.core.PROTOCOL_SENTINEL;
|
||||
|
||||
cljs.core.async.impl.buffers.FixedBuffer.prototype.cljs$core$async$impl$protocols$Buffer$full_QMARK_$arity$1 = (function (this$){
|
||||
var self__ = this;
|
||||
var this$__$1 = this;
|
||||
return (self__.buf.length === self__.n);
|
||||
});
|
||||
|
||||
cljs.core.async.impl.buffers.FixedBuffer.prototype.cljs$core$async$impl$protocols$Buffer$remove_BANG_$arity$1 = (function (this$){
|
||||
var self__ = this;
|
||||
var this$__$1 = this;
|
||||
return self__.buf.pop();
|
||||
});
|
||||
|
||||
cljs.core.async.impl.buffers.FixedBuffer.prototype.cljs$core$async$impl$protocols$Buffer$add_BANG__STAR_$arity$2 = (function (this$,itm){
|
||||
var self__ = this;
|
||||
var this$__$1 = this;
|
||||
self__.buf.unbounded_unshift(itm);
|
||||
|
||||
return this$__$1;
|
||||
});
|
||||
|
||||
cljs.core.async.impl.buffers.FixedBuffer.prototype.cljs$core$async$impl$protocols$Buffer$close_buf_BANG_$arity$1 = (function (this$){
|
||||
var self__ = this;
|
||||
var this$__$1 = this;
|
||||
return null;
|
||||
});
|
||||
|
||||
cljs.core.async.impl.buffers.FixedBuffer.prototype.cljs$core$ICounted$_count$arity$1 = (function (this$){
|
||||
var self__ = this;
|
||||
var this$__$1 = this;
|
||||
return self__.buf.length;
|
||||
});
|
||||
|
||||
cljs.core.async.impl.buffers.FixedBuffer.getBasis = (function (){
|
||||
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Symbol(null,"buf","buf",1426618187,null),new cljs.core.Symbol(null,"n","n",-2092305744,null)], null);
|
||||
});
|
||||
|
||||
cljs.core.async.impl.buffers.FixedBuffer.cljs$lang$type = true;
|
||||
|
||||
cljs.core.async.impl.buffers.FixedBuffer.cljs$lang$ctorStr = "cljs.core.async.impl.buffers/FixedBuffer";
|
||||
|
||||
cljs.core.async.impl.buffers.FixedBuffer.cljs$lang$ctorPrWriter = (function (this__4374__auto__,writer__4375__auto__,opt__4376__auto__){
|
||||
return cljs.core._write.call(null,writer__4375__auto__,"cljs.core.async.impl.buffers/FixedBuffer");
|
||||
});
|
||||
|
||||
/**
|
||||
* Positional factory function for cljs.core.async.impl.buffers/FixedBuffer.
|
||||
*/
|
||||
cljs.core.async.impl.buffers.__GT_FixedBuffer = (function cljs$core$async$impl$buffers$__GT_FixedBuffer(buf,n){
|
||||
return (new cljs.core.async.impl.buffers.FixedBuffer(buf,n));
|
||||
});
|
||||
|
||||
cljs.core.async.impl.buffers.fixed_buffer = (function cljs$core$async$impl$buffers$fixed_buffer(n){
|
||||
return (new cljs.core.async.impl.buffers.FixedBuffer(cljs.core.async.impl.buffers.ring_buffer.call(null,n),n));
|
||||
});
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @implements {cljs.core.ICounted}
|
||||
* @implements {cljs.core.async.impl.protocols.UnblockingBuffer}
|
||||
* @implements {cljs.core.async.impl.protocols.Buffer}
|
||||
*/
|
||||
cljs.core.async.impl.buffers.DroppingBuffer = (function (buf,n){
|
||||
this.buf = buf;
|
||||
this.n = n;
|
||||
this.cljs$lang$protocol_mask$partition0$ = 2;
|
||||
this.cljs$lang$protocol_mask$partition1$ = 0;
|
||||
});
|
||||
cljs.core.async.impl.buffers.DroppingBuffer.prototype.cljs$core$async$impl$protocols$UnblockingBuffer$ = cljs.core.PROTOCOL_SENTINEL;
|
||||
|
||||
cljs.core.async.impl.buffers.DroppingBuffer.prototype.cljs$core$async$impl$protocols$Buffer$ = cljs.core.PROTOCOL_SENTINEL;
|
||||
|
||||
cljs.core.async.impl.buffers.DroppingBuffer.prototype.cljs$core$async$impl$protocols$Buffer$full_QMARK_$arity$1 = (function (this$){
|
||||
var self__ = this;
|
||||
var this$__$1 = this;
|
||||
return false;
|
||||
});
|
||||
|
||||
cljs.core.async.impl.buffers.DroppingBuffer.prototype.cljs$core$async$impl$protocols$Buffer$remove_BANG_$arity$1 = (function (this$){
|
||||
var self__ = this;
|
||||
var this$__$1 = this;
|
||||
return self__.buf.pop();
|
||||
});
|
||||
|
||||
cljs.core.async.impl.buffers.DroppingBuffer.prototype.cljs$core$async$impl$protocols$Buffer$add_BANG__STAR_$arity$2 = (function (this$,itm){
|
||||
var self__ = this;
|
||||
var this$__$1 = this;
|
||||
if((self__.buf.length === self__.n)){
|
||||
} else {
|
||||
self__.buf.unshift(itm);
|
||||
}
|
||||
|
||||
return this$__$1;
|
||||
});
|
||||
|
||||
cljs.core.async.impl.buffers.DroppingBuffer.prototype.cljs$core$async$impl$protocols$Buffer$close_buf_BANG_$arity$1 = (function (this$){
|
||||
var self__ = this;
|
||||
var this$__$1 = this;
|
||||
return null;
|
||||
});
|
||||
|
||||
cljs.core.async.impl.buffers.DroppingBuffer.prototype.cljs$core$ICounted$_count$arity$1 = (function (this$){
|
||||
var self__ = this;
|
||||
var this$__$1 = this;
|
||||
return self__.buf.length;
|
||||
});
|
||||
|
||||
cljs.core.async.impl.buffers.DroppingBuffer.getBasis = (function (){
|
||||
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Symbol(null,"buf","buf",1426618187,null),new cljs.core.Symbol(null,"n","n",-2092305744,null)], null);
|
||||
});
|
||||
|
||||
cljs.core.async.impl.buffers.DroppingBuffer.cljs$lang$type = true;
|
||||
|
||||
cljs.core.async.impl.buffers.DroppingBuffer.cljs$lang$ctorStr = "cljs.core.async.impl.buffers/DroppingBuffer";
|
||||
|
||||
cljs.core.async.impl.buffers.DroppingBuffer.cljs$lang$ctorPrWriter = (function (this__4374__auto__,writer__4375__auto__,opt__4376__auto__){
|
||||
return cljs.core._write.call(null,writer__4375__auto__,"cljs.core.async.impl.buffers/DroppingBuffer");
|
||||
});
|
||||
|
||||
/**
|
||||
* Positional factory function for cljs.core.async.impl.buffers/DroppingBuffer.
|
||||
*/
|
||||
cljs.core.async.impl.buffers.__GT_DroppingBuffer = (function cljs$core$async$impl$buffers$__GT_DroppingBuffer(buf,n){
|
||||
return (new cljs.core.async.impl.buffers.DroppingBuffer(buf,n));
|
||||
});
|
||||
|
||||
cljs.core.async.impl.buffers.dropping_buffer = (function cljs$core$async$impl$buffers$dropping_buffer(n){
|
||||
return (new cljs.core.async.impl.buffers.DroppingBuffer(cljs.core.async.impl.buffers.ring_buffer.call(null,n),n));
|
||||
});
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @implements {cljs.core.ICounted}
|
||||
* @implements {cljs.core.async.impl.protocols.UnblockingBuffer}
|
||||
* @implements {cljs.core.async.impl.protocols.Buffer}
|
||||
*/
|
||||
cljs.core.async.impl.buffers.SlidingBuffer = (function (buf,n){
|
||||
this.buf = buf;
|
||||
this.n = n;
|
||||
this.cljs$lang$protocol_mask$partition0$ = 2;
|
||||
this.cljs$lang$protocol_mask$partition1$ = 0;
|
||||
});
|
||||
cljs.core.async.impl.buffers.SlidingBuffer.prototype.cljs$core$async$impl$protocols$UnblockingBuffer$ = cljs.core.PROTOCOL_SENTINEL;
|
||||
|
||||
cljs.core.async.impl.buffers.SlidingBuffer.prototype.cljs$core$async$impl$protocols$Buffer$ = cljs.core.PROTOCOL_SENTINEL;
|
||||
|
||||
cljs.core.async.impl.buffers.SlidingBuffer.prototype.cljs$core$async$impl$protocols$Buffer$full_QMARK_$arity$1 = (function (this$){
|
||||
var self__ = this;
|
||||
var this$__$1 = this;
|
||||
return false;
|
||||
});
|
||||
|
||||
cljs.core.async.impl.buffers.SlidingBuffer.prototype.cljs$core$async$impl$protocols$Buffer$remove_BANG_$arity$1 = (function (this$){
|
||||
var self__ = this;
|
||||
var this$__$1 = this;
|
||||
return self__.buf.pop();
|
||||
});
|
||||
|
||||
cljs.core.async.impl.buffers.SlidingBuffer.prototype.cljs$core$async$impl$protocols$Buffer$add_BANG__STAR_$arity$2 = (function (this$,itm){
|
||||
var self__ = this;
|
||||
var this$__$1 = this;
|
||||
if((self__.buf.length === self__.n)){
|
||||
cljs.core.async.impl.protocols.remove_BANG_.call(null,this$__$1);
|
||||
} else {
|
||||
}
|
||||
|
||||
self__.buf.unshift(itm);
|
||||
|
||||
return this$__$1;
|
||||
});
|
||||
|
||||
cljs.core.async.impl.buffers.SlidingBuffer.prototype.cljs$core$async$impl$protocols$Buffer$close_buf_BANG_$arity$1 = (function (this$){
|
||||
var self__ = this;
|
||||
var this$__$1 = this;
|
||||
return null;
|
||||
});
|
||||
|
||||
cljs.core.async.impl.buffers.SlidingBuffer.prototype.cljs$core$ICounted$_count$arity$1 = (function (this$){
|
||||
var self__ = this;
|
||||
var this$__$1 = this;
|
||||
return self__.buf.length;
|
||||
});
|
||||
|
||||
cljs.core.async.impl.buffers.SlidingBuffer.getBasis = (function (){
|
||||
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Symbol(null,"buf","buf",1426618187,null),new cljs.core.Symbol(null,"n","n",-2092305744,null)], null);
|
||||
});
|
||||
|
||||
cljs.core.async.impl.buffers.SlidingBuffer.cljs$lang$type = true;
|
||||
|
||||
cljs.core.async.impl.buffers.SlidingBuffer.cljs$lang$ctorStr = "cljs.core.async.impl.buffers/SlidingBuffer";
|
||||
|
||||
cljs.core.async.impl.buffers.SlidingBuffer.cljs$lang$ctorPrWriter = (function (this__4374__auto__,writer__4375__auto__,opt__4376__auto__){
|
||||
return cljs.core._write.call(null,writer__4375__auto__,"cljs.core.async.impl.buffers/SlidingBuffer");
|
||||
});
|
||||
|
||||
/**
|
||||
* Positional factory function for cljs.core.async.impl.buffers/SlidingBuffer.
|
||||
*/
|
||||
cljs.core.async.impl.buffers.__GT_SlidingBuffer = (function cljs$core$async$impl$buffers$__GT_SlidingBuffer(buf,n){
|
||||
return (new cljs.core.async.impl.buffers.SlidingBuffer(buf,n));
|
||||
});
|
||||
|
||||
cljs.core.async.impl.buffers.sliding_buffer = (function cljs$core$async$impl$buffers$sliding_buffer(n){
|
||||
return (new cljs.core.async.impl.buffers.SlidingBuffer(cljs.core.async.impl.buffers.ring_buffer.call(null,n),n));
|
||||
});
|
||||
if((typeof cljs !== 'undefined') && (typeof cljs.core !== 'undefined') && (typeof cljs.core.async !== 'undefined') && (typeof cljs.core.async.impl !== 'undefined') && (typeof cljs.core.async.impl.buffers !== 'undefined') && (typeof cljs.core.async.impl.buffers.NO_VAL !== 'undefined')){
|
||||
} else {
|
||||
cljs.core.async.impl.buffers.NO_VAL = (new Object());
|
||||
}
|
||||
cljs.core.async.impl.buffers.undelivered_QMARK_ = (function cljs$core$async$impl$buffers$undelivered_QMARK_(val){
|
||||
return (cljs.core.async.impl.buffers.NO_VAL === val);
|
||||
});
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @implements {cljs.core.ICounted}
|
||||
* @implements {cljs.core.async.impl.protocols.UnblockingBuffer}
|
||||
* @implements {cljs.core.async.impl.protocols.Buffer}
|
||||
*/
|
||||
cljs.core.async.impl.buffers.PromiseBuffer = (function (val){
|
||||
this.val = val;
|
||||
this.cljs$lang$protocol_mask$partition0$ = 2;
|
||||
this.cljs$lang$protocol_mask$partition1$ = 0;
|
||||
});
|
||||
cljs.core.async.impl.buffers.PromiseBuffer.prototype.cljs$core$async$impl$protocols$UnblockingBuffer$ = cljs.core.PROTOCOL_SENTINEL;
|
||||
|
||||
cljs.core.async.impl.buffers.PromiseBuffer.prototype.cljs$core$async$impl$protocols$Buffer$ = cljs.core.PROTOCOL_SENTINEL;
|
||||
|
||||
cljs.core.async.impl.buffers.PromiseBuffer.prototype.cljs$core$async$impl$protocols$Buffer$full_QMARK_$arity$1 = (function (_){
|
||||
var self__ = this;
|
||||
var ___$1 = this;
|
||||
return false;
|
||||
});
|
||||
|
||||
cljs.core.async.impl.buffers.PromiseBuffer.prototype.cljs$core$async$impl$protocols$Buffer$remove_BANG_$arity$1 = (function (_){
|
||||
var self__ = this;
|
||||
var ___$1 = this;
|
||||
return self__.val;
|
||||
});
|
||||
|
||||
cljs.core.async.impl.buffers.PromiseBuffer.prototype.cljs$core$async$impl$protocols$Buffer$add_BANG__STAR_$arity$2 = (function (this$,itm){
|
||||
var self__ = this;
|
||||
var this$__$1 = this;
|
||||
if(cljs.core.async.impl.buffers.undelivered_QMARK_.call(null,self__.val)){
|
||||
self__.val = itm;
|
||||
} else {
|
||||
}
|
||||
|
||||
return this$__$1;
|
||||
});
|
||||
|
||||
cljs.core.async.impl.buffers.PromiseBuffer.prototype.cljs$core$async$impl$protocols$Buffer$close_buf_BANG_$arity$1 = (function (_){
|
||||
var self__ = this;
|
||||
var ___$1 = this;
|
||||
if(cljs.core.async.impl.buffers.undelivered_QMARK_.call(null,self__.val)){
|
||||
return self__.val = null;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
cljs.core.async.impl.buffers.PromiseBuffer.prototype.cljs$core$ICounted$_count$arity$1 = (function (_){
|
||||
var self__ = this;
|
||||
var ___$1 = this;
|
||||
if(cljs.core.async.impl.buffers.undelivered_QMARK_.call(null,self__.val)){
|
||||
return (0);
|
||||
} else {
|
||||
return (1);
|
||||
}
|
||||
});
|
||||
|
||||
cljs.core.async.impl.buffers.PromiseBuffer.getBasis = (function (){
|
||||
return new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, [cljs.core.with_meta(new cljs.core.Symbol(null,"val","val",1769233139,null),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"mutable","mutable",875778266),true], null))], null);
|
||||
});
|
||||
|
||||
cljs.core.async.impl.buffers.PromiseBuffer.cljs$lang$type = true;
|
||||
|
||||
cljs.core.async.impl.buffers.PromiseBuffer.cljs$lang$ctorStr = "cljs.core.async.impl.buffers/PromiseBuffer";
|
||||
|
||||
cljs.core.async.impl.buffers.PromiseBuffer.cljs$lang$ctorPrWriter = (function (this__4374__auto__,writer__4375__auto__,opt__4376__auto__){
|
||||
return cljs.core._write.call(null,writer__4375__auto__,"cljs.core.async.impl.buffers/PromiseBuffer");
|
||||
});
|
||||
|
||||
/**
|
||||
* Positional factory function for cljs.core.async.impl.buffers/PromiseBuffer.
|
||||
*/
|
||||
cljs.core.async.impl.buffers.__GT_PromiseBuffer = (function cljs$core$async$impl$buffers$__GT_PromiseBuffer(val){
|
||||
return (new cljs.core.async.impl.buffers.PromiseBuffer(val));
|
||||
});
|
||||
|
||||
cljs.core.async.impl.buffers.promise_buffer = (function cljs$core$async$impl$buffers$promise_buffer(){
|
||||
return (new cljs.core.async.impl.buffers.PromiseBuffer(cljs.core.async.impl.buffers.NO_VAL));
|
||||
});
|
||||
|
||||
//# sourceMappingURL=buffers.js.map
|
||||
File diff suppressed because one or more lines are too long
|
|
@ -0,0 +1,192 @@
|
|||
;; Copyright (c) Rich Hickey and contributors. All rights reserved.
|
||||
;; The use and distribution terms for this software are covered by the
|
||||
;; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
|
||||
;; which can be found in the file epl-v10.html at the root of this distribution.
|
||||
;; By using this software in any fashion, you are agreeing to be bound by
|
||||
;; the terms of this license.
|
||||
;; You must not remove this notice, or any other, from this software.
|
||||
|
||||
(ns cljs.core.async.impl.channels
|
||||
(:require [cljs.core.async.impl.protocols :as impl]
|
||||
[cljs.core.async.impl.dispatch :as dispatch]
|
||||
[cljs.core.async.impl.buffers :as buffers]))
|
||||
|
||||
|
||||
|
||||
(defn box [val]
|
||||
(reify cljs.core/IDeref
|
||||
(-deref [_] val)))
|
||||
|
||||
(deftype PutBox [handler val])
|
||||
|
||||
(defn put-active? [box]
|
||||
(impl/active? (.-handler box)))
|
||||
|
||||
(def ^:const MAX_DIRTY 64)
|
||||
|
||||
(defprotocol MMC
|
||||
(abort [this]))
|
||||
|
||||
(deftype ManyToManyChannel [takes ^:mutable dirty-takes puts ^:mutable dirty-puts ^not-native buf ^:mutable closed add!]
|
||||
MMC
|
||||
(abort [this]
|
||||
(loop []
|
||||
(let [putter (.pop puts)]
|
||||
(when-not (nil? putter)
|
||||
(let [^not-native put-handler (.-handler putter)
|
||||
val (.-val putter)]
|
||||
(if ^boolean (impl/active? put-handler)
|
||||
(let [put-cb (impl/commit put-handler)]
|
||||
(dispatch/run #(put-cb true)))
|
||||
(recur))))))
|
||||
(.cleanup puts (constantly false))
|
||||
(impl/close! this))
|
||||
impl/WritePort
|
||||
(put! [this val ^not-native handler]
|
||||
(assert (not (nil? val)) "Can't put nil on a channel")
|
||||
;; bug in CLJS compiler boolean inference - David
|
||||
(let [^boolean closed closed]
|
||||
(if (or closed (not ^boolean (impl/active? handler)))
|
||||
(box (not closed))
|
||||
(if (and buf (not (impl/full? buf)))
|
||||
(do
|
||||
(impl/commit handler)
|
||||
(let [done? (reduced? (add! buf val))
|
||||
take-cbs (loop [takers []]
|
||||
(if (and (pos? (.-length takes)) (pos? (count buf)))
|
||||
(let [^not-native taker (.pop takes)]
|
||||
(if ^boolean (impl/active? taker)
|
||||
(let [ret (impl/commit taker)
|
||||
val (impl/remove! buf)]
|
||||
(recur (conj takers (fn [] (ret val)))))
|
||||
(recur takers)))
|
||||
takers))]
|
||||
(when done? (abort this))
|
||||
(when (seq take-cbs)
|
||||
(doseq [f take-cbs]
|
||||
(dispatch/run f)))
|
||||
(box true)))
|
||||
(let [taker (loop []
|
||||
(let [^not-native taker (.pop takes)]
|
||||
(when taker
|
||||
(if (impl/active? taker)
|
||||
taker
|
||||
(recur)))))]
|
||||
(if taker
|
||||
(let [take-cb (impl/commit taker)]
|
||||
(impl/commit handler)
|
||||
(dispatch/run (fn [] (take-cb val)))
|
||||
(box true))
|
||||
(do
|
||||
(if (> dirty-puts MAX_DIRTY)
|
||||
(do (set! dirty-puts 0)
|
||||
(.cleanup puts put-active?))
|
||||
(set! dirty-puts (inc dirty-puts)))
|
||||
(when (impl/blockable? handler)
|
||||
(assert (< (.-length puts) impl/MAX-QUEUE-SIZE)
|
||||
(str "No more than " impl/MAX-QUEUE-SIZE
|
||||
" pending puts are allowed on a single channel."
|
||||
" Consider using a windowed buffer."))
|
||||
(.unbounded-unshift puts (PutBox. handler val)))
|
||||
nil)))))))
|
||||
impl/ReadPort
|
||||
(take! [this ^not-native handler]
|
||||
(if (not ^boolean (impl/active? handler))
|
||||
nil
|
||||
(if (and (not (nil? buf)) (pos? (count buf)))
|
||||
(do
|
||||
(if-let [take-cb (impl/commit handler)]
|
||||
(let [val (impl/remove! buf)
|
||||
[done? cbs] (when (pos? (.-length puts))
|
||||
(loop [cbs []]
|
||||
(let [putter (.pop puts)
|
||||
^not-native put-handler (.-handler putter)
|
||||
val (.-val putter)
|
||||
cb (and ^boolean (impl/active? put-handler) (impl/commit put-handler))
|
||||
cbs (if cb (conj cbs cb) cbs)
|
||||
done? (when cb (reduced? (add! buf val)))]
|
||||
(if (and (not done?) (not (impl/full? buf)) (pos? (.-length puts)))
|
||||
(recur cbs)
|
||||
[done? cbs]))))]
|
||||
(when done?
|
||||
(abort this))
|
||||
(doseq [cb cbs]
|
||||
(dispatch/run #(cb true)))
|
||||
(box val))))
|
||||
(let [putter (loop []
|
||||
(let [putter (.pop puts)]
|
||||
(when putter
|
||||
(if ^boolean (impl/active? (.-handler putter))
|
||||
putter
|
||||
(recur)))))]
|
||||
(if putter
|
||||
(let [put-cb (impl/commit (.-handler putter))]
|
||||
(impl/commit handler)
|
||||
(dispatch/run #(put-cb true))
|
||||
(box (.-val putter)))
|
||||
(if closed
|
||||
(do
|
||||
(when buf (add! buf))
|
||||
(if (and (impl/active? handler) (impl/commit handler))
|
||||
(let [has-val (and buf (pos? (count buf)))]
|
||||
(let [val (when has-val (impl/remove! buf))]
|
||||
(box val)))
|
||||
nil))
|
||||
(do
|
||||
(if (> dirty-takes MAX_DIRTY)
|
||||
(do (set! dirty-takes 0)
|
||||
(.cleanup takes impl/active?))
|
||||
(set! dirty-takes (inc dirty-takes)))
|
||||
(when (impl/blockable? handler)
|
||||
(assert (< (.-length takes) impl/MAX-QUEUE-SIZE)
|
||||
(str "No more than " impl/MAX-QUEUE-SIZE
|
||||
" pending takes are allowed on a single channel."))
|
||||
(.unbounded-unshift takes handler))
|
||||
nil)))))))
|
||||
impl/Channel
|
||||
(closed? [_] closed)
|
||||
(close! [this]
|
||||
(if ^boolean closed
|
||||
nil
|
||||
(do (set! closed true)
|
||||
(when (and buf (zero? (.-length puts)))
|
||||
(add! buf))
|
||||
(loop []
|
||||
(let [^not-native taker (.pop takes)]
|
||||
(when-not (nil? taker)
|
||||
(when ^boolean (impl/active? taker)
|
||||
(let [take-cb (impl/commit taker)
|
||||
val (when (and buf (pos? (count buf))) (impl/remove! buf))]
|
||||
(dispatch/run (fn [] (take-cb val)))))
|
||||
(recur))))
|
||||
(when buf (impl/close-buf! buf))
|
||||
nil))))
|
||||
|
||||
(defn- ex-handler [ex]
|
||||
(.log js/console ex)
|
||||
nil)
|
||||
|
||||
(defn- handle [buf exh t]
|
||||
(let [else ((or exh ex-handler) t)]
|
||||
(if (nil? else)
|
||||
buf
|
||||
(impl/add! buf else))))
|
||||
|
||||
(defn chan
|
||||
([buf] (chan buf nil))
|
||||
([buf xform] (chan buf xform nil))
|
||||
([buf xform exh]
|
||||
(ManyToManyChannel. (buffers/ring-buffer 32) 0 (buffers/ring-buffer 32)
|
||||
0 buf false
|
||||
(let [add! (if xform (xform impl/add!) impl/add!)]
|
||||
(fn
|
||||
([buf]
|
||||
(try
|
||||
(add! buf)
|
||||
(catch :default t
|
||||
(handle buf exh t))))
|
||||
([buf val]
|
||||
(try
|
||||
(add! buf val)
|
||||
(catch :default t
|
||||
(handle buf exh t)))))))))
|
||||
File diff suppressed because one or more lines are too long
|
|
@ -0,0 +1,685 @@
|
|||
// Compiled by ClojureScript 1.10.520 {}
|
||||
goog.provide('cljs.core.async.impl.channels');
|
||||
goog.require('cljs.core');
|
||||
goog.require('cljs.core.async.impl.protocols');
|
||||
goog.require('cljs.core.async.impl.dispatch');
|
||||
goog.require('cljs.core.async.impl.buffers');
|
||||
cljs.core.async.impl.channels.box = (function cljs$core$async$impl$channels$box(val){
|
||||
if((typeof cljs !== 'undefined') && (typeof cljs.core !== 'undefined') && (typeof cljs.core.async !== 'undefined') && (typeof cljs.core.async.impl !== 'undefined') && (typeof cljs.core.async.impl.channels !== 'undefined') && (typeof cljs.core.async.impl.channels.t_cljs$core$async$impl$channels21540 !== 'undefined')){
|
||||
} else {
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @implements {cljs.core.IMeta}
|
||||
* @implements {cljs.core.IDeref}
|
||||
* @implements {cljs.core.IWithMeta}
|
||||
*/
|
||||
cljs.core.async.impl.channels.t_cljs$core$async$impl$channels21540 = (function (val,meta21541){
|
||||
this.val = val;
|
||||
this.meta21541 = meta21541;
|
||||
this.cljs$lang$protocol_mask$partition0$ = 425984;
|
||||
this.cljs$lang$protocol_mask$partition1$ = 0;
|
||||
});
|
||||
cljs.core.async.impl.channels.t_cljs$core$async$impl$channels21540.prototype.cljs$core$IWithMeta$_with_meta$arity$2 = (function (_21542,meta21541__$1){
|
||||
var self__ = this;
|
||||
var _21542__$1 = this;
|
||||
return (new cljs.core.async.impl.channels.t_cljs$core$async$impl$channels21540(self__.val,meta21541__$1));
|
||||
});
|
||||
|
||||
cljs.core.async.impl.channels.t_cljs$core$async$impl$channels21540.prototype.cljs$core$IMeta$_meta$arity$1 = (function (_21542){
|
||||
var self__ = this;
|
||||
var _21542__$1 = this;
|
||||
return self__.meta21541;
|
||||
});
|
||||
|
||||
cljs.core.async.impl.channels.t_cljs$core$async$impl$channels21540.prototype.cljs$core$IDeref$_deref$arity$1 = (function (_){
|
||||
var self__ = this;
|
||||
var ___$1 = this;
|
||||
return self__.val;
|
||||
});
|
||||
|
||||
cljs.core.async.impl.channels.t_cljs$core$async$impl$channels21540.getBasis = (function (){
|
||||
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Symbol(null,"val","val",1769233139,null),new cljs.core.Symbol(null,"meta21541","meta21541",1619881287,null)], null);
|
||||
});
|
||||
|
||||
cljs.core.async.impl.channels.t_cljs$core$async$impl$channels21540.cljs$lang$type = true;
|
||||
|
||||
cljs.core.async.impl.channels.t_cljs$core$async$impl$channels21540.cljs$lang$ctorStr = "cljs.core.async.impl.channels/t_cljs$core$async$impl$channels21540";
|
||||
|
||||
cljs.core.async.impl.channels.t_cljs$core$async$impl$channels21540.cljs$lang$ctorPrWriter = (function (this__4374__auto__,writer__4375__auto__,opt__4376__auto__){
|
||||
return cljs.core._write.call(null,writer__4375__auto__,"cljs.core.async.impl.channels/t_cljs$core$async$impl$channels21540");
|
||||
});
|
||||
|
||||
/**
|
||||
* Positional factory function for cljs.core.async.impl.channels/t_cljs$core$async$impl$channels21540.
|
||||
*/
|
||||
cljs.core.async.impl.channels.__GT_t_cljs$core$async$impl$channels21540 = (function cljs$core$async$impl$channels$box_$___GT_t_cljs$core$async$impl$channels21540(val__$1,meta21541){
|
||||
return (new cljs.core.async.impl.channels.t_cljs$core$async$impl$channels21540(val__$1,meta21541));
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
return (new cljs.core.async.impl.channels.t_cljs$core$async$impl$channels21540(val,cljs.core.PersistentArrayMap.EMPTY));
|
||||
});
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
cljs.core.async.impl.channels.PutBox = (function (handler,val){
|
||||
this.handler = handler;
|
||||
this.val = val;
|
||||
});
|
||||
|
||||
cljs.core.async.impl.channels.PutBox.getBasis = (function (){
|
||||
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Symbol(null,"handler","handler",1444934915,null),new cljs.core.Symbol(null,"val","val",1769233139,null)], null);
|
||||
});
|
||||
|
||||
cljs.core.async.impl.channels.PutBox.cljs$lang$type = true;
|
||||
|
||||
cljs.core.async.impl.channels.PutBox.cljs$lang$ctorStr = "cljs.core.async.impl.channels/PutBox";
|
||||
|
||||
cljs.core.async.impl.channels.PutBox.cljs$lang$ctorPrWriter = (function (this__4374__auto__,writer__4375__auto__,opt__4376__auto__){
|
||||
return cljs.core._write.call(null,writer__4375__auto__,"cljs.core.async.impl.channels/PutBox");
|
||||
});
|
||||
|
||||
/**
|
||||
* Positional factory function for cljs.core.async.impl.channels/PutBox.
|
||||
*/
|
||||
cljs.core.async.impl.channels.__GT_PutBox = (function cljs$core$async$impl$channels$__GT_PutBox(handler,val){
|
||||
return (new cljs.core.async.impl.channels.PutBox(handler,val));
|
||||
});
|
||||
|
||||
cljs.core.async.impl.channels.put_active_QMARK_ = (function cljs$core$async$impl$channels$put_active_QMARK_(box){
|
||||
return cljs.core.async.impl.protocols.active_QMARK_.call(null,box.handler);
|
||||
});
|
||||
cljs.core.async.impl.channels.MAX_DIRTY = (64);
|
||||
|
||||
/**
|
||||
* @interface
|
||||
*/
|
||||
cljs.core.async.impl.channels.MMC = function(){};
|
||||
|
||||
cljs.core.async.impl.channels.abort = (function cljs$core$async$impl$channels$abort(this$){
|
||||
if((((!((this$ == null)))) && ((!((this$.cljs$core$async$impl$channels$MMC$abort$arity$1 == null)))))){
|
||||
return this$.cljs$core$async$impl$channels$MMC$abort$arity$1(this$);
|
||||
} else {
|
||||
var x__4433__auto__ = (((this$ == null))?null:this$);
|
||||
var m__4434__auto__ = (cljs.core.async.impl.channels.abort[goog.typeOf(x__4433__auto__)]);
|
||||
if((!((m__4434__auto__ == null)))){
|
||||
return m__4434__auto__.call(null,this$);
|
||||
} else {
|
||||
var m__4431__auto__ = (cljs.core.async.impl.channels.abort["_"]);
|
||||
if((!((m__4431__auto__ == null)))){
|
||||
return m__4431__auto__.call(null,this$);
|
||||
} else {
|
||||
throw cljs.core.missing_protocol.call(null,"MMC.abort",this$);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @implements {cljs.core.async.impl.channels.MMC}
|
||||
* @implements {cljs.core.async.impl.protocols.Channel}
|
||||
* @implements {cljs.core.async.impl.protocols.WritePort}
|
||||
* @implements {cljs.core.async.impl.protocols.ReadPort}
|
||||
*/
|
||||
cljs.core.async.impl.channels.ManyToManyChannel = (function (takes,dirty_takes,puts,dirty_puts,buf,closed,add_BANG_){
|
||||
this.takes = takes;
|
||||
this.dirty_takes = dirty_takes;
|
||||
this.puts = puts;
|
||||
this.dirty_puts = dirty_puts;
|
||||
this.buf = buf;
|
||||
this.closed = closed;
|
||||
this.add_BANG_ = add_BANG_;
|
||||
});
|
||||
cljs.core.async.impl.channels.ManyToManyChannel.prototype.cljs$core$async$impl$channels$MMC$ = cljs.core.PROTOCOL_SENTINEL;
|
||||
|
||||
cljs.core.async.impl.channels.ManyToManyChannel.prototype.cljs$core$async$impl$channels$MMC$abort$arity$1 = (function (this$){
|
||||
var self__ = this;
|
||||
var this$__$1 = this;
|
||||
while(true){
|
||||
var putter_21554 = self__.puts.pop();
|
||||
if((putter_21554 == null)){
|
||||
} else {
|
||||
var put_handler_21555 = putter_21554.handler;
|
||||
var val_21556 = putter_21554.val;
|
||||
if(cljs.core.async.impl.protocols.active_QMARK_.call(null,put_handler_21555)){
|
||||
var put_cb_21557 = cljs.core.async.impl.protocols.commit.call(null,put_handler_21555);
|
||||
cljs.core.async.impl.dispatch.run.call(null,((function (put_cb_21557,put_handler_21555,val_21556,putter_21554,this$__$1){
|
||||
return (function (){
|
||||
return put_cb_21557.call(null,true);
|
||||
});})(put_cb_21557,put_handler_21555,val_21556,putter_21554,this$__$1))
|
||||
);
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
self__.puts.cleanup(cljs.core.constantly.call(null,false));
|
||||
|
||||
return cljs.core.async.impl.protocols.close_BANG_.call(null,this$__$1);
|
||||
});
|
||||
|
||||
cljs.core.async.impl.channels.ManyToManyChannel.prototype.cljs$core$async$impl$protocols$WritePort$ = cljs.core.PROTOCOL_SENTINEL;
|
||||
|
||||
cljs.core.async.impl.channels.ManyToManyChannel.prototype.cljs$core$async$impl$protocols$WritePort$put_BANG_$arity$3 = (function (this$,val,handler){
|
||||
var self__ = this;
|
||||
var this$__$1 = this;
|
||||
if((!((val == null)))){
|
||||
} else {
|
||||
throw (new Error(["Assert failed: ","Can't put nil on a channel","\n","(not (nil? val))"].join('')));
|
||||
}
|
||||
|
||||
var closed__$1 = self__.closed;
|
||||
if(((closed__$1) || ((!(cljs.core.async.impl.protocols.active_QMARK_.call(null,handler)))))){
|
||||
return cljs.core.async.impl.channels.box.call(null,(!(closed__$1)));
|
||||
} else {
|
||||
if(cljs.core.truth_((function (){var and__4120__auto__ = self__.buf;
|
||||
if(cljs.core.truth_(and__4120__auto__)){
|
||||
return cljs.core.not.call(null,cljs.core.async.impl.protocols.full_QMARK_.call(null,self__.buf));
|
||||
} else {
|
||||
return and__4120__auto__;
|
||||
}
|
||||
})())){
|
||||
cljs.core.async.impl.protocols.commit.call(null,handler);
|
||||
|
||||
var done_QMARK_ = cljs.core.reduced_QMARK_.call(null,self__.add_BANG_.call(null,self__.buf,val));
|
||||
var take_cbs = (function (){var takers = cljs.core.PersistentVector.EMPTY;
|
||||
while(true){
|
||||
if((((self__.takes.length > (0))) && ((cljs.core.count.call(null,self__.buf) > (0))))){
|
||||
var taker = self__.takes.pop();
|
||||
if(cljs.core.async.impl.protocols.active_QMARK_.call(null,taker)){
|
||||
var ret = cljs.core.async.impl.protocols.commit.call(null,taker);
|
||||
var val__$1 = cljs.core.async.impl.protocols.remove_BANG_.call(null,self__.buf);
|
||||
var G__21558 = cljs.core.conj.call(null,takers,((function (takers,ret,val__$1,taker,done_QMARK_,closed__$1,this$__$1){
|
||||
return (function (){
|
||||
return ret.call(null,val__$1);
|
||||
});})(takers,ret,val__$1,taker,done_QMARK_,closed__$1,this$__$1))
|
||||
);
|
||||
takers = G__21558;
|
||||
continue;
|
||||
} else {
|
||||
var G__21559 = takers;
|
||||
takers = G__21559;
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
return takers;
|
||||
}
|
||||
break;
|
||||
}
|
||||
})();
|
||||
if(done_QMARK_){
|
||||
cljs.core.async.impl.channels.abort.call(null,this$__$1);
|
||||
} else {
|
||||
}
|
||||
|
||||
if(cljs.core.seq.call(null,take_cbs)){
|
||||
var seq__21543_21560 = cljs.core.seq.call(null,take_cbs);
|
||||
var chunk__21544_21561 = null;
|
||||
var count__21545_21562 = (0);
|
||||
var i__21546_21563 = (0);
|
||||
while(true){
|
||||
if((i__21546_21563 < count__21545_21562)){
|
||||
var f_21564 = cljs.core._nth.call(null,chunk__21544_21561,i__21546_21563);
|
||||
cljs.core.async.impl.dispatch.run.call(null,f_21564);
|
||||
|
||||
|
||||
var G__21565 = seq__21543_21560;
|
||||
var G__21566 = chunk__21544_21561;
|
||||
var G__21567 = count__21545_21562;
|
||||
var G__21568 = (i__21546_21563 + (1));
|
||||
seq__21543_21560 = G__21565;
|
||||
chunk__21544_21561 = G__21566;
|
||||
count__21545_21562 = G__21567;
|
||||
i__21546_21563 = G__21568;
|
||||
continue;
|
||||
} else {
|
||||
var temp__5720__auto___21569 = cljs.core.seq.call(null,seq__21543_21560);
|
||||
if(temp__5720__auto___21569){
|
||||
var seq__21543_21570__$1 = temp__5720__auto___21569;
|
||||
if(cljs.core.chunked_seq_QMARK_.call(null,seq__21543_21570__$1)){
|
||||
var c__4550__auto___21571 = cljs.core.chunk_first.call(null,seq__21543_21570__$1);
|
||||
var G__21572 = cljs.core.chunk_rest.call(null,seq__21543_21570__$1);
|
||||
var G__21573 = c__4550__auto___21571;
|
||||
var G__21574 = cljs.core.count.call(null,c__4550__auto___21571);
|
||||
var G__21575 = (0);
|
||||
seq__21543_21560 = G__21572;
|
||||
chunk__21544_21561 = G__21573;
|
||||
count__21545_21562 = G__21574;
|
||||
i__21546_21563 = G__21575;
|
||||
continue;
|
||||
} else {
|
||||
var f_21576 = cljs.core.first.call(null,seq__21543_21570__$1);
|
||||
cljs.core.async.impl.dispatch.run.call(null,f_21576);
|
||||
|
||||
|
||||
var G__21577 = cljs.core.next.call(null,seq__21543_21570__$1);
|
||||
var G__21578 = null;
|
||||
var G__21579 = (0);
|
||||
var G__21580 = (0);
|
||||
seq__21543_21560 = G__21577;
|
||||
chunk__21544_21561 = G__21578;
|
||||
count__21545_21562 = G__21579;
|
||||
i__21546_21563 = G__21580;
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
|
||||
return cljs.core.async.impl.channels.box.call(null,true);
|
||||
} else {
|
||||
var taker = (function (){while(true){
|
||||
var taker = self__.takes.pop();
|
||||
if(cljs.core.truth_(taker)){
|
||||
if(cljs.core.truth_(cljs.core.async.impl.protocols.active_QMARK_.call(null,taker))){
|
||||
return taker;
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
break;
|
||||
}
|
||||
})();
|
||||
if(cljs.core.truth_(taker)){
|
||||
var take_cb = cljs.core.async.impl.protocols.commit.call(null,taker);
|
||||
cljs.core.async.impl.protocols.commit.call(null,handler);
|
||||
|
||||
cljs.core.async.impl.dispatch.run.call(null,((function (take_cb,taker,closed__$1,this$__$1){
|
||||
return (function (){
|
||||
return take_cb.call(null,val);
|
||||
});})(take_cb,taker,closed__$1,this$__$1))
|
||||
);
|
||||
|
||||
return cljs.core.async.impl.channels.box.call(null,true);
|
||||
} else {
|
||||
if((self__.dirty_puts > (64))){
|
||||
self__.dirty_puts = (0);
|
||||
|
||||
self__.puts.cleanup(cljs.core.async.impl.channels.put_active_QMARK_);
|
||||
} else {
|
||||
self__.dirty_puts = (self__.dirty_puts + (1));
|
||||
}
|
||||
|
||||
if(cljs.core.truth_(cljs.core.async.impl.protocols.blockable_QMARK_.call(null,handler))){
|
||||
if((self__.puts.length < (1024))){
|
||||
} else {
|
||||
throw (new Error(["Assert failed: ",["No more than ",cljs.core.str.cljs$core$IFn$_invoke$arity$1((1024))," pending puts are allowed on a single channel."," Consider using a windowed buffer."].join(''),"\n","(< (.-length puts) impl/MAX-QUEUE-SIZE)"].join('')));
|
||||
}
|
||||
|
||||
self__.puts.unbounded_unshift((new cljs.core.async.impl.channels.PutBox(handler,val)));
|
||||
} else {
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
cljs.core.async.impl.channels.ManyToManyChannel.prototype.cljs$core$async$impl$protocols$ReadPort$ = cljs.core.PROTOCOL_SENTINEL;
|
||||
|
||||
cljs.core.async.impl.channels.ManyToManyChannel.prototype.cljs$core$async$impl$protocols$ReadPort$take_BANG_$arity$2 = (function (this$,handler){
|
||||
var self__ = this;
|
||||
var this$__$1 = this;
|
||||
if((!(cljs.core.async.impl.protocols.active_QMARK_.call(null,handler)))){
|
||||
return null;
|
||||
} else {
|
||||
if((((!((self__.buf == null)))) && ((cljs.core.count.call(null,self__.buf) > (0))))){
|
||||
var temp__5718__auto__ = cljs.core.async.impl.protocols.commit.call(null,handler);
|
||||
if(cljs.core.truth_(temp__5718__auto__)){
|
||||
var take_cb = temp__5718__auto__;
|
||||
var val = cljs.core.async.impl.protocols.remove_BANG_.call(null,self__.buf);
|
||||
var vec__21547 = (((self__.puts.length > (0)))?(function (){var cbs = cljs.core.PersistentVector.EMPTY;
|
||||
while(true){
|
||||
var putter = self__.puts.pop();
|
||||
var put_handler = putter.handler;
|
||||
var val__$1 = putter.val;
|
||||
var cb = (function (){var and__4120__auto__ = cljs.core.async.impl.protocols.active_QMARK_.call(null,put_handler);
|
||||
if(and__4120__auto__){
|
||||
return cljs.core.async.impl.protocols.commit.call(null,put_handler);
|
||||
} else {
|
||||
return and__4120__auto__;
|
||||
}
|
||||
})();
|
||||
var cbs__$1 = (cljs.core.truth_(cb)?cljs.core.conj.call(null,cbs,cb):cbs);
|
||||
var done_QMARK_ = (cljs.core.truth_(cb)?cljs.core.reduced_QMARK_.call(null,self__.add_BANG_.call(null,self__.buf,val__$1)):null);
|
||||
if(((cljs.core.not.call(null,done_QMARK_)) && (cljs.core.not.call(null,cljs.core.async.impl.protocols.full_QMARK_.call(null,self__.buf))) && ((self__.puts.length > (0))))){
|
||||
var G__21581 = cbs__$1;
|
||||
cbs = G__21581;
|
||||
continue;
|
||||
} else {
|
||||
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [done_QMARK_,cbs__$1], null);
|
||||
}
|
||||
break;
|
||||
}
|
||||
})():null);
|
||||
var done_QMARK_ = cljs.core.nth.call(null,vec__21547,(0),null);
|
||||
var cbs = cljs.core.nth.call(null,vec__21547,(1),null);
|
||||
if(cljs.core.truth_(done_QMARK_)){
|
||||
cljs.core.async.impl.channels.abort.call(null,this$__$1);
|
||||
} else {
|
||||
}
|
||||
|
||||
var seq__21550_21582 = cljs.core.seq.call(null,cbs);
|
||||
var chunk__21551_21583 = null;
|
||||
var count__21552_21584 = (0);
|
||||
var i__21553_21585 = (0);
|
||||
while(true){
|
||||
if((i__21553_21585 < count__21552_21584)){
|
||||
var cb_21586 = cljs.core._nth.call(null,chunk__21551_21583,i__21553_21585);
|
||||
cljs.core.async.impl.dispatch.run.call(null,((function (seq__21550_21582,chunk__21551_21583,count__21552_21584,i__21553_21585,cb_21586,val,vec__21547,done_QMARK_,cbs,take_cb,temp__5718__auto__,this$__$1){
|
||||
return (function (){
|
||||
return cb_21586.call(null,true);
|
||||
});})(seq__21550_21582,chunk__21551_21583,count__21552_21584,i__21553_21585,cb_21586,val,vec__21547,done_QMARK_,cbs,take_cb,temp__5718__auto__,this$__$1))
|
||||
);
|
||||
|
||||
|
||||
var G__21587 = seq__21550_21582;
|
||||
var G__21588 = chunk__21551_21583;
|
||||
var G__21589 = count__21552_21584;
|
||||
var G__21590 = (i__21553_21585 + (1));
|
||||
seq__21550_21582 = G__21587;
|
||||
chunk__21551_21583 = G__21588;
|
||||
count__21552_21584 = G__21589;
|
||||
i__21553_21585 = G__21590;
|
||||
continue;
|
||||
} else {
|
||||
var temp__5720__auto___21591 = cljs.core.seq.call(null,seq__21550_21582);
|
||||
if(temp__5720__auto___21591){
|
||||
var seq__21550_21592__$1 = temp__5720__auto___21591;
|
||||
if(cljs.core.chunked_seq_QMARK_.call(null,seq__21550_21592__$1)){
|
||||
var c__4550__auto___21593 = cljs.core.chunk_first.call(null,seq__21550_21592__$1);
|
||||
var G__21594 = cljs.core.chunk_rest.call(null,seq__21550_21592__$1);
|
||||
var G__21595 = c__4550__auto___21593;
|
||||
var G__21596 = cljs.core.count.call(null,c__4550__auto___21593);
|
||||
var G__21597 = (0);
|
||||
seq__21550_21582 = G__21594;
|
||||
chunk__21551_21583 = G__21595;
|
||||
count__21552_21584 = G__21596;
|
||||
i__21553_21585 = G__21597;
|
||||
continue;
|
||||
} else {
|
||||
var cb_21598 = cljs.core.first.call(null,seq__21550_21592__$1);
|
||||
cljs.core.async.impl.dispatch.run.call(null,((function (seq__21550_21582,chunk__21551_21583,count__21552_21584,i__21553_21585,cb_21598,seq__21550_21592__$1,temp__5720__auto___21591,val,vec__21547,done_QMARK_,cbs,take_cb,temp__5718__auto__,this$__$1){
|
||||
return (function (){
|
||||
return cb_21598.call(null,true);
|
||||
});})(seq__21550_21582,chunk__21551_21583,count__21552_21584,i__21553_21585,cb_21598,seq__21550_21592__$1,temp__5720__auto___21591,val,vec__21547,done_QMARK_,cbs,take_cb,temp__5718__auto__,this$__$1))
|
||||
);
|
||||
|
||||
|
||||
var G__21599 = cljs.core.next.call(null,seq__21550_21592__$1);
|
||||
var G__21600 = null;
|
||||
var G__21601 = (0);
|
||||
var G__21602 = (0);
|
||||
seq__21550_21582 = G__21599;
|
||||
chunk__21551_21583 = G__21600;
|
||||
count__21552_21584 = G__21601;
|
||||
i__21553_21585 = G__21602;
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return cljs.core.async.impl.channels.box.call(null,val);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
var putter = (function (){while(true){
|
||||
var putter = self__.puts.pop();
|
||||
if(cljs.core.truth_(putter)){
|
||||
if(cljs.core.async.impl.protocols.active_QMARK_.call(null,putter.handler)){
|
||||
return putter;
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
break;
|
||||
}
|
||||
})();
|
||||
if(cljs.core.truth_(putter)){
|
||||
var put_cb = cljs.core.async.impl.protocols.commit.call(null,putter.handler);
|
||||
cljs.core.async.impl.protocols.commit.call(null,handler);
|
||||
|
||||
cljs.core.async.impl.dispatch.run.call(null,((function (put_cb,putter,this$__$1){
|
||||
return (function (){
|
||||
return put_cb.call(null,true);
|
||||
});})(put_cb,putter,this$__$1))
|
||||
);
|
||||
|
||||
return cljs.core.async.impl.channels.box.call(null,putter.val);
|
||||
} else {
|
||||
if(cljs.core.truth_(self__.closed)){
|
||||
if(cljs.core.truth_(self__.buf)){
|
||||
self__.add_BANG_.call(null,self__.buf);
|
||||
} else {
|
||||
}
|
||||
|
||||
if(cljs.core.truth_((function (){var and__4120__auto__ = cljs.core.async.impl.protocols.active_QMARK_.call(null,handler);
|
||||
if(cljs.core.truth_(and__4120__auto__)){
|
||||
return cljs.core.async.impl.protocols.commit.call(null,handler);
|
||||
} else {
|
||||
return and__4120__auto__;
|
||||
}
|
||||
})())){
|
||||
var has_val = (function (){var and__4120__auto__ = self__.buf;
|
||||
if(cljs.core.truth_(and__4120__auto__)){
|
||||
return (cljs.core.count.call(null,self__.buf) > (0));
|
||||
} else {
|
||||
return and__4120__auto__;
|
||||
}
|
||||
})();
|
||||
var val = (cljs.core.truth_(has_val)?cljs.core.async.impl.protocols.remove_BANG_.call(null,self__.buf):null);
|
||||
return cljs.core.async.impl.channels.box.call(null,val);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
if((self__.dirty_takes > (64))){
|
||||
self__.dirty_takes = (0);
|
||||
|
||||
self__.takes.cleanup(cljs.core.async.impl.protocols.active_QMARK_);
|
||||
} else {
|
||||
self__.dirty_takes = (self__.dirty_takes + (1));
|
||||
}
|
||||
|
||||
if(cljs.core.truth_(cljs.core.async.impl.protocols.blockable_QMARK_.call(null,handler))){
|
||||
if((self__.takes.length < (1024))){
|
||||
} else {
|
||||
throw (new Error(["Assert failed: ",["No more than ",cljs.core.str.cljs$core$IFn$_invoke$arity$1((1024))," pending takes are allowed on a single channel."].join(''),"\n","(< (.-length takes) impl/MAX-QUEUE-SIZE)"].join('')));
|
||||
}
|
||||
|
||||
self__.takes.unbounded_unshift(handler);
|
||||
} else {
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
cljs.core.async.impl.channels.ManyToManyChannel.prototype.cljs$core$async$impl$protocols$Channel$ = cljs.core.PROTOCOL_SENTINEL;
|
||||
|
||||
cljs.core.async.impl.channels.ManyToManyChannel.prototype.cljs$core$async$impl$protocols$Channel$closed_QMARK_$arity$1 = (function (_){
|
||||
var self__ = this;
|
||||
var ___$1 = this;
|
||||
return self__.closed;
|
||||
});
|
||||
|
||||
cljs.core.async.impl.channels.ManyToManyChannel.prototype.cljs$core$async$impl$protocols$Channel$close_BANG_$arity$1 = (function (this$){
|
||||
var self__ = this;
|
||||
var this$__$1 = this;
|
||||
if(self__.closed){
|
||||
return null;
|
||||
} else {
|
||||
self__.closed = true;
|
||||
|
||||
if(cljs.core.truth_((function (){var and__4120__auto__ = self__.buf;
|
||||
if(cljs.core.truth_(and__4120__auto__)){
|
||||
return (self__.puts.length === (0));
|
||||
} else {
|
||||
return and__4120__auto__;
|
||||
}
|
||||
})())){
|
||||
self__.add_BANG_.call(null,self__.buf);
|
||||
} else {
|
||||
}
|
||||
|
||||
while(true){
|
||||
var taker_21603 = self__.takes.pop();
|
||||
if((taker_21603 == null)){
|
||||
} else {
|
||||
if(cljs.core.async.impl.protocols.active_QMARK_.call(null,taker_21603)){
|
||||
var take_cb_21604 = cljs.core.async.impl.protocols.commit.call(null,taker_21603);
|
||||
var val_21605 = (cljs.core.truth_((function (){var and__4120__auto__ = self__.buf;
|
||||
if(cljs.core.truth_(and__4120__auto__)){
|
||||
return (cljs.core.count.call(null,self__.buf) > (0));
|
||||
} else {
|
||||
return and__4120__auto__;
|
||||
}
|
||||
})())?cljs.core.async.impl.protocols.remove_BANG_.call(null,self__.buf):null);
|
||||
cljs.core.async.impl.dispatch.run.call(null,((function (take_cb_21604,val_21605,taker_21603,this$__$1){
|
||||
return (function (){
|
||||
return take_cb_21604.call(null,val_21605);
|
||||
});})(take_cb_21604,val_21605,taker_21603,this$__$1))
|
||||
);
|
||||
} else {
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if(cljs.core.truth_(self__.buf)){
|
||||
cljs.core.async.impl.protocols.close_buf_BANG_.call(null,self__.buf);
|
||||
} else {
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
cljs.core.async.impl.channels.ManyToManyChannel.getBasis = (function (){
|
||||
return new cljs.core.PersistentVector(null, 7, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Symbol(null,"takes","takes",298247964,null),cljs.core.with_meta(new cljs.core.Symbol(null,"dirty-takes","dirty-takes",575642138,null),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"mutable","mutable",875778266),true], null)),new cljs.core.Symbol(null,"puts","puts",-1883877054,null),cljs.core.with_meta(new cljs.core.Symbol(null,"dirty-puts","dirty-puts",57041148,null),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"mutable","mutable",875778266),true], null)),cljs.core.with_meta(new cljs.core.Symbol(null,"buf","buf",1426618187,null),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"tag","tag",-1290361223),new cljs.core.Symbol(null,"not-native","not-native",-236392494,null)], null)),cljs.core.with_meta(new cljs.core.Symbol(null,"closed","closed",720856168,null),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"mutable","mutable",875778266),true], null)),new cljs.core.Symbol(null,"add!","add!",2046056845,null)], null);
|
||||
});
|
||||
|
||||
cljs.core.async.impl.channels.ManyToManyChannel.cljs$lang$type = true;
|
||||
|
||||
cljs.core.async.impl.channels.ManyToManyChannel.cljs$lang$ctorStr = "cljs.core.async.impl.channels/ManyToManyChannel";
|
||||
|
||||
cljs.core.async.impl.channels.ManyToManyChannel.cljs$lang$ctorPrWriter = (function (this__4374__auto__,writer__4375__auto__,opt__4376__auto__){
|
||||
return cljs.core._write.call(null,writer__4375__auto__,"cljs.core.async.impl.channels/ManyToManyChannel");
|
||||
});
|
||||
|
||||
/**
|
||||
* Positional factory function for cljs.core.async.impl.channels/ManyToManyChannel.
|
||||
*/
|
||||
cljs.core.async.impl.channels.__GT_ManyToManyChannel = (function cljs$core$async$impl$channels$__GT_ManyToManyChannel(takes,dirty_takes,puts,dirty_puts,buf,closed,add_BANG_){
|
||||
return (new cljs.core.async.impl.channels.ManyToManyChannel(takes,dirty_takes,puts,dirty_puts,buf,closed,add_BANG_));
|
||||
});
|
||||
|
||||
cljs.core.async.impl.channels.ex_handler = (function cljs$core$async$impl$channels$ex_handler(ex){
|
||||
console.log(ex);
|
||||
|
||||
return null;
|
||||
});
|
||||
cljs.core.async.impl.channels.handle = (function cljs$core$async$impl$channels$handle(buf,exh,t){
|
||||
var else$ = (function (){var or__4131__auto__ = exh;
|
||||
if(cljs.core.truth_(or__4131__auto__)){
|
||||
return or__4131__auto__;
|
||||
} else {
|
||||
return cljs.core.async.impl.channels.ex_handler;
|
||||
}
|
||||
})().call(null,t);
|
||||
if((else$ == null)){
|
||||
return buf;
|
||||
} else {
|
||||
return cljs.core.async.impl.protocols.add_BANG_.call(null,buf,else$);
|
||||
}
|
||||
});
|
||||
cljs.core.async.impl.channels.chan = (function cljs$core$async$impl$channels$chan(var_args){
|
||||
var G__21607 = arguments.length;
|
||||
switch (G__21607) {
|
||||
case 1:
|
||||
return cljs.core.async.impl.channels.chan.cljs$core$IFn$_invoke$arity$1((arguments[(0)]));
|
||||
|
||||
break;
|
||||
case 2:
|
||||
return cljs.core.async.impl.channels.chan.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)]));
|
||||
|
||||
break;
|
||||
case 3:
|
||||
return cljs.core.async.impl.channels.chan.cljs$core$IFn$_invoke$arity$3((arguments[(0)]),(arguments[(1)]),(arguments[(2)]));
|
||||
|
||||
break;
|
||||
default:
|
||||
throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
cljs.core.async.impl.channels.chan.cljs$core$IFn$_invoke$arity$1 = (function (buf){
|
||||
return cljs.core.async.impl.channels.chan.call(null,buf,null);
|
||||
});
|
||||
|
||||
cljs.core.async.impl.channels.chan.cljs$core$IFn$_invoke$arity$2 = (function (buf,xform){
|
||||
return cljs.core.async.impl.channels.chan.call(null,buf,xform,null);
|
||||
});
|
||||
|
||||
cljs.core.async.impl.channels.chan.cljs$core$IFn$_invoke$arity$3 = (function (buf,xform,exh){
|
||||
return (new cljs.core.async.impl.channels.ManyToManyChannel(cljs.core.async.impl.buffers.ring_buffer.call(null,(32)),(0),cljs.core.async.impl.buffers.ring_buffer.call(null,(32)),(0),buf,false,(function (){var add_BANG_ = (cljs.core.truth_(xform)?xform.call(null,cljs.core.async.impl.protocols.add_BANG_):cljs.core.async.impl.protocols.add_BANG_);
|
||||
return ((function (add_BANG_){
|
||||
return (function() {
|
||||
var G__21611 = null;
|
||||
var G__21611__1 = (function (buf__$1){
|
||||
try{return add_BANG_.call(null,buf__$1);
|
||||
}catch (e21608){var t = e21608;
|
||||
return cljs.core.async.impl.channels.handle.call(null,buf__$1,exh,t);
|
||||
}});
|
||||
var G__21611__2 = (function (buf__$1,val){
|
||||
try{return add_BANG_.call(null,buf__$1,val);
|
||||
}catch (e21609){var t = e21609;
|
||||
return cljs.core.async.impl.channels.handle.call(null,buf__$1,exh,t);
|
||||
}});
|
||||
G__21611 = function(buf__$1,val){
|
||||
switch(arguments.length){
|
||||
case 1:
|
||||
return G__21611__1.call(this,buf__$1);
|
||||
case 2:
|
||||
return G__21611__2.call(this,buf__$1,val);
|
||||
}
|
||||
throw(new Error('Invalid arity: ' + arguments.length));
|
||||
};
|
||||
G__21611.cljs$core$IFn$_invoke$arity$1 = G__21611__1;
|
||||
G__21611.cljs$core$IFn$_invoke$arity$2 = G__21611__2;
|
||||
return G__21611;
|
||||
})()
|
||||
;})(add_BANG_))
|
||||
})()));
|
||||
});
|
||||
|
||||
cljs.core.async.impl.channels.chan.cljs$lang$maxFixedArity = 3;
|
||||
|
||||
|
||||
//# sourceMappingURL=channels.js.map
|
||||
File diff suppressed because one or more lines are too long
|
|
@ -0,0 +1,37 @@
|
|||
(ns cljs.core.async.impl.dispatch
|
||||
(:require [cljs.core.async.impl.buffers :as buffers]
|
||||
[goog.async.nextTick]))
|
||||
|
||||
(def tasks (buffers/ring-buffer 32))
|
||||
(def running? false)
|
||||
(def queued? false)
|
||||
|
||||
(def TASK_BATCH_SIZE 1024)
|
||||
|
||||
(declare queue-dispatcher)
|
||||
|
||||
(defn process-messages []
|
||||
(set! running? true)
|
||||
(set! queued? false)
|
||||
(loop [count 0]
|
||||
(let [m (.pop tasks)]
|
||||
(when-not (nil? m)
|
||||
(m)
|
||||
(when (< count TASK_BATCH_SIZE)
|
||||
(recur (inc count))))))
|
||||
(set! running? false)
|
||||
(when (> (.-length tasks) 0)
|
||||
(queue-dispatcher)))
|
||||
|
||||
(defn queue-dispatcher []
|
||||
(when-not (and queued? running?)
|
||||
(set! queued? true)
|
||||
(goog.async.nextTick process-messages)))
|
||||
|
||||
(defn run [f]
|
||||
(.unbounded-unshift tasks f)
|
||||
(queue-dispatcher))
|
||||
|
||||
(defn queue-delay [f delay]
|
||||
(js/setTimeout f delay))
|
||||
|
||||
|
|
@ -0,0 +1 @@
|
|||
["^ ","~:rename-macros",["^ "],"~:renames",["^ "],"~:externs",["^ ","~$setTimeout",["^ "]],"~:use-macros",["^ "],"~:excludes",["~#set",[]],"~:name","~$cljs.core.async.impl.dispatch","~:imports",null,"~:requires",["^ ","~$buffers","~$cljs.core.async.impl.buffers","^<","^<","~$goog.async.nextTick","^="],"~:cljs.spec/speced-vars",[],"~:uses",null,"~:defs",["^ ","~$tasks",["^ ","^7","~$cljs.core.async.impl.dispatch/tasks","~:file","target/cljsbuild-compiler-1/cljs/core/async/impl/dispatch.cljs","~:line",5,"~:column",1,"~:end-line",5,"~:end-column",11,"~:meta",["^ ","^C","/home/simon/workspace/geocsv-lite/target/cljsbuild-compiler-1/cljs/core/async/impl/dispatch.cljs","^D",5,"^E",6,"^F",5,"^G",11],"~:tag","~$cljs.core.async.impl.buffers/RingBuffer"],"~$running?",["^ ","^7","~$cljs.core.async.impl.dispatch/running?","^C","target/cljsbuild-compiler-1/cljs/core/async/impl/dispatch.cljs","^D",6,"^E",1,"^F",6,"^G",14,"^H",["^ ","^C","/home/simon/workspace/geocsv-lite/target/cljsbuild-compiler-1/cljs/core/async/impl/dispatch.cljs","^D",6,"^E",6,"^F",6,"^G",14],"^I","~$boolean"],"~$queued?",["^ ","^7","~$cljs.core.async.impl.dispatch/queued?","^C","target/cljsbuild-compiler-1/cljs/core/async/impl/dispatch.cljs","^D",7,"^E",1,"^F",7,"^G",13,"^H",["^ ","^C","/home/simon/workspace/geocsv-lite/target/cljsbuild-compiler-1/cljs/core/async/impl/dispatch.cljs","^D",7,"^E",6,"^F",7,"^G",13],"^I","^M"],"~$TASK_BATCH_SIZE",["^ ","^7","~$cljs.core.async.impl.dispatch/TASK_BATCH_SIZE","^C","target/cljsbuild-compiler-1/cljs/core/async/impl/dispatch.cljs","^D",9,"^E",1,"^F",9,"^G",21,"^H",["^ ","^C","/home/simon/workspace/geocsv-lite/target/cljsbuild-compiler-1/cljs/core/async/impl/dispatch.cljs","^D",9,"^E",6,"^F",9,"^G",21],"^I","~$number"],"~$queue-dispatcher",["^ ","~:protocol-inline",null,"^H",["^ ","^C","/home/simon/workspace/geocsv-lite/target/cljsbuild-compiler-1/cljs/core/async/impl/dispatch.cljs","^D",26,"^E",7,"^F",26,"^G",23,"~:arglists",["~#list",["~$quote",["^V",[[]]]]]],"^7","~$cljs.core.async.impl.dispatch/queue-dispatcher","^C","target/cljsbuild-compiler-1/cljs/core/async/impl/dispatch.cljs","^G",23,"~:method-params",["^V",[[]]],"~:protocol-impl",null,"~:arglists-meta",["^V",[null,null]],"^E",1,"~:variadic?",false,"^D",26,"~:ret-tag",["^6",["~$any","~$clj-nil"]],"^F",26,"~:max-fixed-arity",0,"~:fn-var",true,"^U",["^V",["^W",["^V",[[]]]]]],"~$process-messages",["^ ","^T",null,"^H",["^ ","^C","/home/simon/workspace/geocsv-lite/target/cljsbuild-compiler-1/cljs/core/async/impl/dispatch.cljs","^D",13,"^E",7,"^F",13,"^G",23,"^U",["^V",["^W",["^V",[[]]]]]],"^7","~$cljs.core.async.impl.dispatch/process-messages","^C","target/cljsbuild-compiler-1/cljs/core/async/impl/dispatch.cljs","^G",23,"^Y",["^V",[[]]],"^Z",null,"^[",["^V",[null,null]],"^E",1,"^10",false,"^D",13,"^11",["^6",["^12","^13"]],"^F",13,"^14",0,"^15",true,"^U",["^V",["^W",["^V",[[]]]]]],"~$run",["^ ","^T",null,"^H",["^ ","^C","/home/simon/workspace/geocsv-lite/target/cljsbuild-compiler-1/cljs/core/async/impl/dispatch.cljs","^D",31,"^E",7,"^F",31,"^G",10,"^U",["^V",["^W",["^V",[["~$f"]]]]]],"^7","~$cljs.core.async.impl.dispatch/run","^C","target/cljsbuild-compiler-1/cljs/core/async/impl/dispatch.cljs","^G",10,"^Y",["^V",[["~$f"]]],"^Z",null,"^[",["^V",[null,null]],"^E",1,"^10",false,"^D",31,"^11",["^6",["^12","^13"]],"^F",31,"^14",1,"^15",true,"^U",["^V",["^W",["^V",[["~$f"]]]]]],"~$queue-delay",["^ ","^T",null,"^H",["^ ","^C","/home/simon/workspace/geocsv-lite/target/cljsbuild-compiler-1/cljs/core/async/impl/dispatch.cljs","^D",35,"^E",7,"^F",35,"^G",18,"^U",["^V",["^W",["^V",[["~$f","~$delay"]]]]]],"^7","~$cljs.core.async.impl.dispatch/queue-delay","^C","target/cljsbuild-compiler-1/cljs/core/async/impl/dispatch.cljs","^G",18,"^Y",["^V",[["~$f","^1;"]]],"^Z",null,"^[",["^V",[null,null]],"^E",1,"^10",false,"^D",35,"^11","~$js","^F",35,"^14",2,"^15",true,"^U",["^V",["^W",["^V",[["~$f","^1;"]]]]]]],"~:cljs.spec/registry-ref",[],"~:require-macros",null,"~:doc",null]
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
// Compiled by ClojureScript 1.10.520 {}
|
||||
goog.provide('cljs.core.async.impl.dispatch');
|
||||
goog.require('cljs.core');
|
||||
goog.require('cljs.core.async.impl.buffers');
|
||||
goog.require('goog.async.nextTick');
|
||||
cljs.core.async.impl.dispatch.tasks = cljs.core.async.impl.buffers.ring_buffer.call(null,(32));
|
||||
cljs.core.async.impl.dispatch.running_QMARK_ = false;
|
||||
cljs.core.async.impl.dispatch.queued_QMARK_ = false;
|
||||
cljs.core.async.impl.dispatch.TASK_BATCH_SIZE = (1024);
|
||||
cljs.core.async.impl.dispatch.process_messages = (function cljs$core$async$impl$dispatch$process_messages(){
|
||||
cljs.core.async.impl.dispatch.running_QMARK_ = true;
|
||||
|
||||
cljs.core.async.impl.dispatch.queued_QMARK_ = false;
|
||||
|
||||
var count_21535 = (0);
|
||||
while(true){
|
||||
var m_21536 = cljs.core.async.impl.dispatch.tasks.pop();
|
||||
if((m_21536 == null)){
|
||||
} else {
|
||||
m_21536.call(null);
|
||||
|
||||
if((count_21535 < cljs.core.async.impl.dispatch.TASK_BATCH_SIZE)){
|
||||
var G__21537 = (count_21535 + (1));
|
||||
count_21535 = G__21537;
|
||||
continue;
|
||||
} else {
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
cljs.core.async.impl.dispatch.running_QMARK_ = false;
|
||||
|
||||
if((cljs.core.async.impl.dispatch.tasks.length > (0))){
|
||||
return cljs.core.async.impl.dispatch.queue_dispatcher.call(null);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
cljs.core.async.impl.dispatch.queue_dispatcher = (function cljs$core$async$impl$dispatch$queue_dispatcher(){
|
||||
if(((cljs.core.async.impl.dispatch.queued_QMARK_) && (cljs.core.async.impl.dispatch.running_QMARK_))){
|
||||
return null;
|
||||
} else {
|
||||
cljs.core.async.impl.dispatch.queued_QMARK_ = true;
|
||||
|
||||
return goog.async.nextTick.call(null,cljs.core.async.impl.dispatch.process_messages);
|
||||
}
|
||||
});
|
||||
cljs.core.async.impl.dispatch.run = (function cljs$core$async$impl$dispatch$run(f){
|
||||
cljs.core.async.impl.dispatch.tasks.unbounded_unshift(f);
|
||||
|
||||
return cljs.core.async.impl.dispatch.queue_dispatcher.call(null);
|
||||
});
|
||||
cljs.core.async.impl.dispatch.queue_delay = (function cljs$core$async$impl$dispatch$queue_delay(f,delay){
|
||||
return setTimeout(f,delay);
|
||||
});
|
||||
|
||||
//# sourceMappingURL=dispatch.js.map
|
||||
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"\/home\/simon\/workspace\/geocsv-lite\/target\/cljsbuild-compiler-1\/cljs\/core\/async\/impl\/dispatch.js","sources":["dispatch.cljs"],"lineCount":58,"mappings":";AAAA;;;;AAIA,AAAKA,sCAAM,mDAAA,nDAACC;AACZ,+CAAA,\/CAAKC;AACL,8CAAA,9CAAKC;AAEL,gDAAA,hDAAKC;AAEL,AAAA,AAEA,iDAAA,jDAAMC;AAAN,AACE,+CAAA,\/CAAMH;;AACN,8CAAA,9CAAMC;;AACN,kBAAA,dAAOG;;AAAP,AACE,IAAMC,UAAE,AAAMP;AAAd,AACE,GAAU,YAAA,XAAMO;AAAhB;AAAA,AACE,AAACA;;AACD,GAAM,CAAGD,cAAMF;AAAf,AACE,eAAO,eAAA,dAAKE;;;;AADd;;;;;AAEN,+CAAA,\/CAAMJ;;AACN,GAAM,8CAAA,7CAAG,AAAUF;AAAnB,AACE,OAACQ;;AADH;;;AAGF,iDAAA,jDAAMA;AAAN,AACE,GAAU,EAAKL,iDAAQD;AAAvB;;AAAA,AACE,8CAAA,9CAAMC;;AACN,OAAC,AAAAM,8BAAoBJ;;;AAEzB,oCAAA,pCAAMK,gFAAKC;AAAX,AACE,AAAoBX,sDAAMW;;AAC1B,OAACH;;AAEH,4CAAA,5CAAMI,gGAAaD,EAAEE;AAArB,AACE,OAACC,WAAcH,EAAEE","names":["cljs.core.async.impl.dispatch\/tasks","cljs.core.async.impl.buffers\/ring-buffer","cljs.core.async.impl.dispatch\/running?","cljs.core.async.impl.dispatch\/queued?","cljs.core.async.impl.dispatch\/TASK_BATCH_SIZE","cljs.core.async.impl.dispatch\/process-messages","count","m","cljs.core.async.impl.dispatch\/queue-dispatcher","goog\/async","cljs.core.async.impl.dispatch\/run","f","cljs.core.async.impl.dispatch\/queue-delay","delay","js\/setTimeout"]}
|
||||
|
|
@ -0,0 +1,146 @@
|
|||
(ns cljs.core.async.impl.ioc-helpers
|
||||
(:require [cljs.core.async.impl.protocols :as impl])
|
||||
(:require-macros [cljs.core.async.impl.ioc-macros :as ioc]))
|
||||
|
||||
(def ^:const FN-IDX 0)
|
||||
(def ^:const STATE-IDX 1)
|
||||
(def ^:const VALUE-IDX 2)
|
||||
(def ^:const BINDINGS-IDX 3)
|
||||
(def ^:const EXCEPTION-FRAMES 4)
|
||||
(def ^:const CURRENT-EXCEPTION 5)
|
||||
(def ^:const USER-START-IDX 6)
|
||||
|
||||
(defn aset-object [arr idx o]
|
||||
(aget arr idx o))
|
||||
|
||||
(defn aget-object [arr idx]
|
||||
(aget arr idx))
|
||||
|
||||
|
||||
(defn finished?
|
||||
"Returns true if the machine is in a finished state"
|
||||
[state-array]
|
||||
(keyword-identical? (aget state-array STATE-IDX) :finished))
|
||||
|
||||
(defn- fn-handler
|
||||
[f]
|
||||
(reify
|
||||
impl/Handler
|
||||
(active? [_] true)
|
||||
(blockable? [_] true)
|
||||
(commit [_] f)))
|
||||
|
||||
|
||||
(defn run-state-machine [state]
|
||||
((aget-object state FN-IDX) state))
|
||||
|
||||
(defn run-state-machine-wrapped [state]
|
||||
(try
|
||||
(run-state-machine state)
|
||||
(catch js/Object ex
|
||||
(impl/close! ^not-native (aget-object state USER-START-IDX))
|
||||
(throw ex))))
|
||||
|
||||
(defn take! [state blk ^not-native c]
|
||||
(if-let [cb (impl/take! c (fn-handler
|
||||
(fn [x]
|
||||
(ioc/aset-all! state VALUE-IDX x STATE-IDX blk)
|
||||
(run-state-machine-wrapped state))))]
|
||||
(do (ioc/aset-all! state VALUE-IDX @cb STATE-IDX blk)
|
||||
:recur)
|
||||
nil))
|
||||
|
||||
(defn put! [state blk ^not-native c val]
|
||||
(if-let [cb (impl/put! c val (fn-handler (fn [ret-val]
|
||||
(ioc/aset-all! state VALUE-IDX ret-val STATE-IDX blk)
|
||||
(run-state-machine-wrapped state))))]
|
||||
(do (ioc/aset-all! state VALUE-IDX @cb STATE-IDX blk)
|
||||
:recur)
|
||||
nil))
|
||||
|
||||
(defn return-chan [state value]
|
||||
(let [^not-native c (aget state USER-START-IDX)]
|
||||
(when-not (nil? value)
|
||||
(impl/put! c value (fn-handler (fn [] nil))))
|
||||
(impl/close! c)
|
||||
c))
|
||||
|
||||
(defrecord ExceptionFrame [catch-block
|
||||
^Class catch-exception
|
||||
finally-block
|
||||
continue-block
|
||||
prev])
|
||||
|
||||
(defn add-exception-frame [state catch-block catch-exception finally-block continue-block]
|
||||
(ioc/aset-all! state
|
||||
EXCEPTION-FRAMES
|
||||
(->ExceptionFrame catch-block
|
||||
catch-exception
|
||||
finally-block
|
||||
continue-block
|
||||
(aget-object state EXCEPTION-FRAMES))))
|
||||
|
||||
(defn process-exception [state]
|
||||
(let [exception-frame (aget-object state EXCEPTION-FRAMES)
|
||||
catch-block (:catch-block exception-frame)
|
||||
catch-exception (:catch-exception exception-frame)
|
||||
exception (aget-object state CURRENT-EXCEPTION)]
|
||||
(cond
|
||||
(and exception
|
||||
(not exception-frame))
|
||||
(throw exception)
|
||||
|
||||
(and exception
|
||||
catch-block
|
||||
(or (= :default catch-exception)
|
||||
(instance? catch-exception exception)))
|
||||
(ioc/aset-all! state
|
||||
STATE-IDX
|
||||
catch-block
|
||||
VALUE-IDX
|
||||
exception
|
||||
CURRENT-EXCEPTION
|
||||
nil
|
||||
EXCEPTION-FRAMES
|
||||
(assoc exception-frame
|
||||
:catch-block nil
|
||||
:catch-exception nil))
|
||||
|
||||
|
||||
(and exception
|
||||
(not catch-block)
|
||||
(not (:finally-block exception-frame)))
|
||||
|
||||
(do (ioc/aset-all! state
|
||||
EXCEPTION-FRAMES
|
||||
(:prev exception-frame))
|
||||
(recur state))
|
||||
|
||||
(and exception
|
||||
(not catch-block)
|
||||
(:finally-block exception-frame))
|
||||
(ioc/aset-all! state
|
||||
STATE-IDX
|
||||
(:finally-block exception-frame)
|
||||
EXCEPTION-FRAMES
|
||||
(assoc exception-frame
|
||||
:finally-block nil))
|
||||
|
||||
(and (not exception)
|
||||
(:finally-block exception-frame))
|
||||
(do (ioc/aset-all! state
|
||||
STATE-IDX
|
||||
(:finally-block exception-frame)
|
||||
EXCEPTION-FRAMES
|
||||
(assoc exception-frame
|
||||
:finally-block nil)))
|
||||
|
||||
(and (not exception)
|
||||
(not (:finally-block exception-frame)))
|
||||
(do (ioc/aset-all! state
|
||||
STATE-IDX
|
||||
(:continue-block exception-frame)
|
||||
EXCEPTION-FRAMES
|
||||
(:prev exception-frame)))
|
||||
|
||||
:else (throw (js/Error. "No matching clause")))))
|
||||
File diff suppressed because one or more lines are too long
|
|
@ -0,0 +1,519 @@
|
|||
// Compiled by ClojureScript 1.10.520 {}
|
||||
goog.provide('cljs.core.async.impl.ioc_helpers');
|
||||
goog.require('cljs.core');
|
||||
goog.require('cljs.core.async.impl.protocols');
|
||||
cljs.core.async.impl.ioc_helpers.FN_IDX = (0);
|
||||
cljs.core.async.impl.ioc_helpers.STATE_IDX = (1);
|
||||
cljs.core.async.impl.ioc_helpers.VALUE_IDX = (2);
|
||||
cljs.core.async.impl.ioc_helpers.BINDINGS_IDX = (3);
|
||||
cljs.core.async.impl.ioc_helpers.EXCEPTION_FRAMES = (4);
|
||||
cljs.core.async.impl.ioc_helpers.CURRENT_EXCEPTION = (5);
|
||||
cljs.core.async.impl.ioc_helpers.USER_START_IDX = (6);
|
||||
cljs.core.async.impl.ioc_helpers.aset_object = (function cljs$core$async$impl$ioc_helpers$aset_object(arr,idx,o){
|
||||
return (arr[idx][o]);
|
||||
});
|
||||
cljs.core.async.impl.ioc_helpers.aget_object = (function cljs$core$async$impl$ioc_helpers$aget_object(arr,idx){
|
||||
return (arr[idx]);
|
||||
});
|
||||
/**
|
||||
* Returns true if the machine is in a finished state
|
||||
*/
|
||||
cljs.core.async.impl.ioc_helpers.finished_QMARK_ = (function cljs$core$async$impl$ioc_helpers$finished_QMARK_(state_array){
|
||||
return cljs.core.keyword_identical_QMARK_.call(null,(state_array[(1)]),new cljs.core.Keyword(null,"finished","finished",-1018867731));
|
||||
});
|
||||
cljs.core.async.impl.ioc_helpers.fn_handler = (function cljs$core$async$impl$ioc_helpers$fn_handler(f){
|
||||
if((typeof cljs !== 'undefined') && (typeof cljs.core !== 'undefined') && (typeof cljs.core.async !== 'undefined') && (typeof cljs.core.async.impl !== 'undefined') && (typeof cljs.core.async.impl.ioc_helpers !== 'undefined') && (typeof cljs.core.async.impl.ioc_helpers.t_cljs$core$async$impl$ioc_helpers23564 !== 'undefined')){
|
||||
} else {
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @implements {cljs.core.async.impl.protocols.Handler}
|
||||
* @implements {cljs.core.IMeta}
|
||||
* @implements {cljs.core.IWithMeta}
|
||||
*/
|
||||
cljs.core.async.impl.ioc_helpers.t_cljs$core$async$impl$ioc_helpers23564 = (function (f,meta23565){
|
||||
this.f = f;
|
||||
this.meta23565 = meta23565;
|
||||
this.cljs$lang$protocol_mask$partition0$ = 393216;
|
||||
this.cljs$lang$protocol_mask$partition1$ = 0;
|
||||
});
|
||||
cljs.core.async.impl.ioc_helpers.t_cljs$core$async$impl$ioc_helpers23564.prototype.cljs$core$IWithMeta$_with_meta$arity$2 = (function (_23566,meta23565__$1){
|
||||
var self__ = this;
|
||||
var _23566__$1 = this;
|
||||
return (new cljs.core.async.impl.ioc_helpers.t_cljs$core$async$impl$ioc_helpers23564(self__.f,meta23565__$1));
|
||||
});
|
||||
|
||||
cljs.core.async.impl.ioc_helpers.t_cljs$core$async$impl$ioc_helpers23564.prototype.cljs$core$IMeta$_meta$arity$1 = (function (_23566){
|
||||
var self__ = this;
|
||||
var _23566__$1 = this;
|
||||
return self__.meta23565;
|
||||
});
|
||||
|
||||
cljs.core.async.impl.ioc_helpers.t_cljs$core$async$impl$ioc_helpers23564.prototype.cljs$core$async$impl$protocols$Handler$ = cljs.core.PROTOCOL_SENTINEL;
|
||||
|
||||
cljs.core.async.impl.ioc_helpers.t_cljs$core$async$impl$ioc_helpers23564.prototype.cljs$core$async$impl$protocols$Handler$active_QMARK_$arity$1 = (function (_){
|
||||
var self__ = this;
|
||||
var ___$1 = this;
|
||||
return true;
|
||||
});
|
||||
|
||||
cljs.core.async.impl.ioc_helpers.t_cljs$core$async$impl$ioc_helpers23564.prototype.cljs$core$async$impl$protocols$Handler$blockable_QMARK_$arity$1 = (function (_){
|
||||
var self__ = this;
|
||||
var ___$1 = this;
|
||||
return true;
|
||||
});
|
||||
|
||||
cljs.core.async.impl.ioc_helpers.t_cljs$core$async$impl$ioc_helpers23564.prototype.cljs$core$async$impl$protocols$Handler$commit$arity$1 = (function (_){
|
||||
var self__ = this;
|
||||
var ___$1 = this;
|
||||
return self__.f;
|
||||
});
|
||||
|
||||
cljs.core.async.impl.ioc_helpers.t_cljs$core$async$impl$ioc_helpers23564.getBasis = (function (){
|
||||
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Symbol(null,"f","f",43394975,null),new cljs.core.Symbol(null,"meta23565","meta23565",1895361404,null)], null);
|
||||
});
|
||||
|
||||
cljs.core.async.impl.ioc_helpers.t_cljs$core$async$impl$ioc_helpers23564.cljs$lang$type = true;
|
||||
|
||||
cljs.core.async.impl.ioc_helpers.t_cljs$core$async$impl$ioc_helpers23564.cljs$lang$ctorStr = "cljs.core.async.impl.ioc-helpers/t_cljs$core$async$impl$ioc_helpers23564";
|
||||
|
||||
cljs.core.async.impl.ioc_helpers.t_cljs$core$async$impl$ioc_helpers23564.cljs$lang$ctorPrWriter = (function (this__4374__auto__,writer__4375__auto__,opt__4376__auto__){
|
||||
return cljs.core._write.call(null,writer__4375__auto__,"cljs.core.async.impl.ioc-helpers/t_cljs$core$async$impl$ioc_helpers23564");
|
||||
});
|
||||
|
||||
/**
|
||||
* Positional factory function for cljs.core.async.impl.ioc-helpers/t_cljs$core$async$impl$ioc_helpers23564.
|
||||
*/
|
||||
cljs.core.async.impl.ioc_helpers.__GT_t_cljs$core$async$impl$ioc_helpers23564 = (function cljs$core$async$impl$ioc_helpers$fn_handler_$___GT_t_cljs$core$async$impl$ioc_helpers23564(f__$1,meta23565){
|
||||
return (new cljs.core.async.impl.ioc_helpers.t_cljs$core$async$impl$ioc_helpers23564(f__$1,meta23565));
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
return (new cljs.core.async.impl.ioc_helpers.t_cljs$core$async$impl$ioc_helpers23564(f,cljs.core.PersistentArrayMap.EMPTY));
|
||||
});
|
||||
cljs.core.async.impl.ioc_helpers.run_state_machine = (function cljs$core$async$impl$ioc_helpers$run_state_machine(state){
|
||||
return cljs.core.async.impl.ioc_helpers.aget_object.call(null,state,(0)).call(null,state);
|
||||
});
|
||||
cljs.core.async.impl.ioc_helpers.run_state_machine_wrapped = (function cljs$core$async$impl$ioc_helpers$run_state_machine_wrapped(state){
|
||||
try{return cljs.core.async.impl.ioc_helpers.run_state_machine.call(null,state);
|
||||
}catch (e23567){if((e23567 instanceof Object)){
|
||||
var ex = e23567;
|
||||
cljs.core.async.impl.protocols.close_BANG_.call(null,cljs.core.async.impl.ioc_helpers.aget_object.call(null,state,(6)));
|
||||
|
||||
throw ex;
|
||||
} else {
|
||||
throw e23567;
|
||||
|
||||
}
|
||||
}});
|
||||
cljs.core.async.impl.ioc_helpers.take_BANG_ = (function cljs$core$async$impl$ioc_helpers$take_BANG_(state,blk,c){
|
||||
var temp__5718__auto__ = cljs.core.async.impl.protocols.take_BANG_.call(null,c,cljs.core.async.impl.ioc_helpers.fn_handler.call(null,(function (x){
|
||||
var statearr_23568_23570 = state;
|
||||
(statearr_23568_23570[(2)] = x);
|
||||
|
||||
(statearr_23568_23570[(1)] = blk);
|
||||
|
||||
|
||||
return cljs.core.async.impl.ioc_helpers.run_state_machine_wrapped.call(null,state);
|
||||
})));
|
||||
if(cljs.core.truth_(temp__5718__auto__)){
|
||||
var cb = temp__5718__auto__;
|
||||
var statearr_23569_23571 = state;
|
||||
(statearr_23569_23571[(2)] = cljs.core.deref.call(null,cb));
|
||||
|
||||
(statearr_23569_23571[(1)] = blk);
|
||||
|
||||
|
||||
return new cljs.core.Keyword(null,"recur","recur",-437573268);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
cljs.core.async.impl.ioc_helpers.put_BANG_ = (function cljs$core$async$impl$ioc_helpers$put_BANG_(state,blk,c,val){
|
||||
var temp__5718__auto__ = cljs.core.async.impl.protocols.put_BANG_.call(null,c,val,cljs.core.async.impl.ioc_helpers.fn_handler.call(null,(function (ret_val){
|
||||
var statearr_23572_23574 = state;
|
||||
(statearr_23572_23574[(2)] = ret_val);
|
||||
|
||||
(statearr_23572_23574[(1)] = blk);
|
||||
|
||||
|
||||
return cljs.core.async.impl.ioc_helpers.run_state_machine_wrapped.call(null,state);
|
||||
})));
|
||||
if(cljs.core.truth_(temp__5718__auto__)){
|
||||
var cb = temp__5718__auto__;
|
||||
var statearr_23573_23575 = state;
|
||||
(statearr_23573_23575[(2)] = cljs.core.deref.call(null,cb));
|
||||
|
||||
(statearr_23573_23575[(1)] = blk);
|
||||
|
||||
|
||||
return new cljs.core.Keyword(null,"recur","recur",-437573268);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
cljs.core.async.impl.ioc_helpers.return_chan = (function cljs$core$async$impl$ioc_helpers$return_chan(state,value){
|
||||
var c = (state[(6)]);
|
||||
if((value == null)){
|
||||
} else {
|
||||
cljs.core.async.impl.protocols.put_BANG_.call(null,c,value,cljs.core.async.impl.ioc_helpers.fn_handler.call(null,((function (c){
|
||||
return (function (){
|
||||
return null;
|
||||
});})(c))
|
||||
));
|
||||
}
|
||||
|
||||
cljs.core.async.impl.protocols.close_BANG_.call(null,c);
|
||||
|
||||
return c;
|
||||
});
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @implements {cljs.core.IRecord}
|
||||
* @implements {cljs.core.IKVReduce}
|
||||
* @implements {cljs.core.IEquiv}
|
||||
* @implements {cljs.core.IHash}
|
||||
* @implements {cljs.core.ICollection}
|
||||
* @implements {cljs.core.ICounted}
|
||||
* @implements {cljs.core.ISeqable}
|
||||
* @implements {cljs.core.IMeta}
|
||||
* @implements {cljs.core.ICloneable}
|
||||
* @implements {cljs.core.IPrintWithWriter}
|
||||
* @implements {cljs.core.IIterable}
|
||||
* @implements {cljs.core.IWithMeta}
|
||||
* @implements {cljs.core.IAssociative}
|
||||
* @implements {cljs.core.IMap}
|
||||
* @implements {cljs.core.ILookup}
|
||||
*/
|
||||
cljs.core.async.impl.ioc_helpers.ExceptionFrame = (function (catch_block,catch_exception,finally_block,continue_block,prev,__meta,__extmap,__hash){
|
||||
this.catch_block = catch_block;
|
||||
this.catch_exception = catch_exception;
|
||||
this.finally_block = finally_block;
|
||||
this.continue_block = continue_block;
|
||||
this.prev = prev;
|
||||
this.__meta = __meta;
|
||||
this.__extmap = __extmap;
|
||||
this.__hash = __hash;
|
||||
this.cljs$lang$protocol_mask$partition0$ = 2230716170;
|
||||
this.cljs$lang$protocol_mask$partition1$ = 139264;
|
||||
});
|
||||
cljs.core.async.impl.ioc_helpers.ExceptionFrame.prototype.cljs$core$ILookup$_lookup$arity$2 = (function (this__4385__auto__,k__4386__auto__){
|
||||
var self__ = this;
|
||||
var this__4385__auto____$1 = this;
|
||||
return this__4385__auto____$1.cljs$core$ILookup$_lookup$arity$3(null,k__4386__auto__,null);
|
||||
});
|
||||
|
||||
cljs.core.async.impl.ioc_helpers.ExceptionFrame.prototype.cljs$core$ILookup$_lookup$arity$3 = (function (this__4387__auto__,k23577,else__4388__auto__){
|
||||
var self__ = this;
|
||||
var this__4387__auto____$1 = this;
|
||||
var G__23581 = k23577;
|
||||
var G__23581__$1 = (((G__23581 instanceof cljs.core.Keyword))?G__23581.fqn:null);
|
||||
switch (G__23581__$1) {
|
||||
case "catch-block":
|
||||
return self__.catch_block;
|
||||
|
||||
break;
|
||||
case "catch-exception":
|
||||
return self__.catch_exception;
|
||||
|
||||
break;
|
||||
case "finally-block":
|
||||
return self__.finally_block;
|
||||
|
||||
break;
|
||||
case "continue-block":
|
||||
return self__.continue_block;
|
||||
|
||||
break;
|
||||
case "prev":
|
||||
return self__.prev;
|
||||
|
||||
break;
|
||||
default:
|
||||
return cljs.core.get.call(null,self__.__extmap,k23577,else__4388__auto__);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
cljs.core.async.impl.ioc_helpers.ExceptionFrame.prototype.cljs$core$IKVReduce$_kv_reduce$arity$3 = (function (this__4404__auto__,f__4405__auto__,init__4406__auto__){
|
||||
var self__ = this;
|
||||
var this__4404__auto____$1 = this;
|
||||
return cljs.core.reduce.call(null,((function (this__4404__auto____$1){
|
||||
return (function (ret__4407__auto__,p__23582){
|
||||
var vec__23583 = p__23582;
|
||||
var k__4408__auto__ = cljs.core.nth.call(null,vec__23583,(0),null);
|
||||
var v__4409__auto__ = cljs.core.nth.call(null,vec__23583,(1),null);
|
||||
return f__4405__auto__.call(null,ret__4407__auto__,k__4408__auto__,v__4409__auto__);
|
||||
});})(this__4404__auto____$1))
|
||||
,init__4406__auto__,this__4404__auto____$1);
|
||||
});
|
||||
|
||||
cljs.core.async.impl.ioc_helpers.ExceptionFrame.prototype.cljs$core$IPrintWithWriter$_pr_writer$arity$3 = (function (this__4399__auto__,writer__4400__auto__,opts__4401__auto__){
|
||||
var self__ = this;
|
||||
var this__4399__auto____$1 = this;
|
||||
var pr_pair__4402__auto__ = ((function (this__4399__auto____$1){
|
||||
return (function (keyval__4403__auto__){
|
||||
return cljs.core.pr_sequential_writer.call(null,writer__4400__auto__,cljs.core.pr_writer,""," ","",opts__4401__auto__,keyval__4403__auto__);
|
||||
});})(this__4399__auto____$1))
|
||||
;
|
||||
return cljs.core.pr_sequential_writer.call(null,writer__4400__auto__,pr_pair__4402__auto__,"#cljs.core.async.impl.ioc-helpers.ExceptionFrame{",", ","}",opts__4401__auto__,cljs.core.concat.call(null,new cljs.core.PersistentVector(null, 5, 5, cljs.core.PersistentVector.EMPTY_NODE, [(new cljs.core.PersistentVector(null,2,(5),cljs.core.PersistentVector.EMPTY_NODE,[new cljs.core.Keyword(null,"catch-block","catch-block",1175212748),self__.catch_block],null)),(new cljs.core.PersistentVector(null,2,(5),cljs.core.PersistentVector.EMPTY_NODE,[new cljs.core.Keyword(null,"catch-exception","catch-exception",-1997306795),self__.catch_exception],null)),(new cljs.core.PersistentVector(null,2,(5),cljs.core.PersistentVector.EMPTY_NODE,[new cljs.core.Keyword(null,"finally-block","finally-block",832982472),self__.finally_block],null)),(new cljs.core.PersistentVector(null,2,(5),cljs.core.PersistentVector.EMPTY_NODE,[new cljs.core.Keyword(null,"continue-block","continue-block",-1852047850),self__.continue_block],null)),(new cljs.core.PersistentVector(null,2,(5),cljs.core.PersistentVector.EMPTY_NODE,[new cljs.core.Keyword(null,"prev","prev",-1597069226),self__.prev],null))], null),self__.__extmap));
|
||||
});
|
||||
|
||||
cljs.core.async.impl.ioc_helpers.ExceptionFrame.prototype.cljs$core$IIterable$_iterator$arity$1 = (function (G__23576){
|
||||
var self__ = this;
|
||||
var G__23576__$1 = this;
|
||||
return (new cljs.core.RecordIter((0),G__23576__$1,5,new cljs.core.PersistentVector(null, 5, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"catch-block","catch-block",1175212748),new cljs.core.Keyword(null,"catch-exception","catch-exception",-1997306795),new cljs.core.Keyword(null,"finally-block","finally-block",832982472),new cljs.core.Keyword(null,"continue-block","continue-block",-1852047850),new cljs.core.Keyword(null,"prev","prev",-1597069226)], null),(cljs.core.truth_(self__.__extmap)?cljs.core._iterator.call(null,self__.__extmap):cljs.core.nil_iter.call(null))));
|
||||
});
|
||||
|
||||
cljs.core.async.impl.ioc_helpers.ExceptionFrame.prototype.cljs$core$IMeta$_meta$arity$1 = (function (this__4383__auto__){
|
||||
var self__ = this;
|
||||
var this__4383__auto____$1 = this;
|
||||
return self__.__meta;
|
||||
});
|
||||
|
||||
cljs.core.async.impl.ioc_helpers.ExceptionFrame.prototype.cljs$core$ICloneable$_clone$arity$1 = (function (this__4380__auto__){
|
||||
var self__ = this;
|
||||
var this__4380__auto____$1 = this;
|
||||
return (new cljs.core.async.impl.ioc_helpers.ExceptionFrame(self__.catch_block,self__.catch_exception,self__.finally_block,self__.continue_block,self__.prev,self__.__meta,self__.__extmap,self__.__hash));
|
||||
});
|
||||
|
||||
cljs.core.async.impl.ioc_helpers.ExceptionFrame.prototype.cljs$core$ICounted$_count$arity$1 = (function (this__4389__auto__){
|
||||
var self__ = this;
|
||||
var this__4389__auto____$1 = this;
|
||||
return (5 + cljs.core.count.call(null,self__.__extmap));
|
||||
});
|
||||
|
||||
cljs.core.async.impl.ioc_helpers.ExceptionFrame.prototype.cljs$core$IHash$_hash$arity$1 = (function (this__4381__auto__){
|
||||
var self__ = this;
|
||||
var this__4381__auto____$1 = this;
|
||||
var h__4243__auto__ = self__.__hash;
|
||||
if((!((h__4243__auto__ == null)))){
|
||||
return h__4243__auto__;
|
||||
} else {
|
||||
var h__4243__auto____$1 = ((function (h__4243__auto__,this__4381__auto____$1){
|
||||
return (function (coll__4382__auto__){
|
||||
return (846900531 ^ cljs.core.hash_unordered_coll.call(null,coll__4382__auto__));
|
||||
});})(h__4243__auto__,this__4381__auto____$1))
|
||||
.call(null,this__4381__auto____$1);
|
||||
self__.__hash = h__4243__auto____$1;
|
||||
|
||||
return h__4243__auto____$1;
|
||||
}
|
||||
});
|
||||
|
||||
cljs.core.async.impl.ioc_helpers.ExceptionFrame.prototype.cljs$core$IEquiv$_equiv$arity$2 = (function (this23578,other23579){
|
||||
var self__ = this;
|
||||
var this23578__$1 = this;
|
||||
return (((!((other23579 == null)))) && ((this23578__$1.constructor === other23579.constructor)) && (cljs.core._EQ_.call(null,this23578__$1.catch_block,other23579.catch_block)) && (cljs.core._EQ_.call(null,this23578__$1.catch_exception,other23579.catch_exception)) && (cljs.core._EQ_.call(null,this23578__$1.finally_block,other23579.finally_block)) && (cljs.core._EQ_.call(null,this23578__$1.continue_block,other23579.continue_block)) && (cljs.core._EQ_.call(null,this23578__$1.prev,other23579.prev)) && (cljs.core._EQ_.call(null,this23578__$1.__extmap,other23579.__extmap)));
|
||||
});
|
||||
|
||||
cljs.core.async.impl.ioc_helpers.ExceptionFrame.prototype.cljs$core$IMap$_dissoc$arity$2 = (function (this__4394__auto__,k__4395__auto__){
|
||||
var self__ = this;
|
||||
var this__4394__auto____$1 = this;
|
||||
if(cljs.core.contains_QMARK_.call(null,new cljs.core.PersistentHashSet(null, new cljs.core.PersistentArrayMap(null, 5, [new cljs.core.Keyword(null,"finally-block","finally-block",832982472),null,new cljs.core.Keyword(null,"catch-block","catch-block",1175212748),null,new cljs.core.Keyword(null,"catch-exception","catch-exception",-1997306795),null,new cljs.core.Keyword(null,"prev","prev",-1597069226),null,new cljs.core.Keyword(null,"continue-block","continue-block",-1852047850),null], null), null),k__4395__auto__)){
|
||||
return cljs.core.dissoc.call(null,cljs.core._with_meta.call(null,cljs.core.into.call(null,cljs.core.PersistentArrayMap.EMPTY,this__4394__auto____$1),self__.__meta),k__4395__auto__);
|
||||
} else {
|
||||
return (new cljs.core.async.impl.ioc_helpers.ExceptionFrame(self__.catch_block,self__.catch_exception,self__.finally_block,self__.continue_block,self__.prev,self__.__meta,cljs.core.not_empty.call(null,cljs.core.dissoc.call(null,self__.__extmap,k__4395__auto__)),null));
|
||||
}
|
||||
});
|
||||
|
||||
cljs.core.async.impl.ioc_helpers.ExceptionFrame.prototype.cljs$core$IAssociative$_assoc$arity$3 = (function (this__4392__auto__,k__4393__auto__,G__23576){
|
||||
var self__ = this;
|
||||
var this__4392__auto____$1 = this;
|
||||
var pred__23586 = cljs.core.keyword_identical_QMARK_;
|
||||
var expr__23587 = k__4393__auto__;
|
||||
if(cljs.core.truth_(pred__23586.call(null,new cljs.core.Keyword(null,"catch-block","catch-block",1175212748),expr__23587))){
|
||||
return (new cljs.core.async.impl.ioc_helpers.ExceptionFrame(G__23576,self__.catch_exception,self__.finally_block,self__.continue_block,self__.prev,self__.__meta,self__.__extmap,null));
|
||||
} else {
|
||||
if(cljs.core.truth_(pred__23586.call(null,new cljs.core.Keyword(null,"catch-exception","catch-exception",-1997306795),expr__23587))){
|
||||
return (new cljs.core.async.impl.ioc_helpers.ExceptionFrame(self__.catch_block,G__23576,self__.finally_block,self__.continue_block,self__.prev,self__.__meta,self__.__extmap,null));
|
||||
} else {
|
||||
if(cljs.core.truth_(pred__23586.call(null,new cljs.core.Keyword(null,"finally-block","finally-block",832982472),expr__23587))){
|
||||
return (new cljs.core.async.impl.ioc_helpers.ExceptionFrame(self__.catch_block,self__.catch_exception,G__23576,self__.continue_block,self__.prev,self__.__meta,self__.__extmap,null));
|
||||
} else {
|
||||
if(cljs.core.truth_(pred__23586.call(null,new cljs.core.Keyword(null,"continue-block","continue-block",-1852047850),expr__23587))){
|
||||
return (new cljs.core.async.impl.ioc_helpers.ExceptionFrame(self__.catch_block,self__.catch_exception,self__.finally_block,G__23576,self__.prev,self__.__meta,self__.__extmap,null));
|
||||
} else {
|
||||
if(cljs.core.truth_(pred__23586.call(null,new cljs.core.Keyword(null,"prev","prev",-1597069226),expr__23587))){
|
||||
return (new cljs.core.async.impl.ioc_helpers.ExceptionFrame(self__.catch_block,self__.catch_exception,self__.finally_block,self__.continue_block,G__23576,self__.__meta,self__.__extmap,null));
|
||||
} else {
|
||||
return (new cljs.core.async.impl.ioc_helpers.ExceptionFrame(self__.catch_block,self__.catch_exception,self__.finally_block,self__.continue_block,self__.prev,self__.__meta,cljs.core.assoc.call(null,self__.__extmap,k__4393__auto__,G__23576),null));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
cljs.core.async.impl.ioc_helpers.ExceptionFrame.prototype.cljs$core$ISeqable$_seq$arity$1 = (function (this__4397__auto__){
|
||||
var self__ = this;
|
||||
var this__4397__auto____$1 = this;
|
||||
return cljs.core.seq.call(null,cljs.core.concat.call(null,new cljs.core.PersistentVector(null, 5, 5, cljs.core.PersistentVector.EMPTY_NODE, [(new cljs.core.MapEntry(new cljs.core.Keyword(null,"catch-block","catch-block",1175212748),self__.catch_block,null)),(new cljs.core.MapEntry(new cljs.core.Keyword(null,"catch-exception","catch-exception",-1997306795),self__.catch_exception,null)),(new cljs.core.MapEntry(new cljs.core.Keyword(null,"finally-block","finally-block",832982472),self__.finally_block,null)),(new cljs.core.MapEntry(new cljs.core.Keyword(null,"continue-block","continue-block",-1852047850),self__.continue_block,null)),(new cljs.core.MapEntry(new cljs.core.Keyword(null,"prev","prev",-1597069226),self__.prev,null))], null),self__.__extmap));
|
||||
});
|
||||
|
||||
cljs.core.async.impl.ioc_helpers.ExceptionFrame.prototype.cljs$core$IWithMeta$_with_meta$arity$2 = (function (this__4384__auto__,G__23576){
|
||||
var self__ = this;
|
||||
var this__4384__auto____$1 = this;
|
||||
return (new cljs.core.async.impl.ioc_helpers.ExceptionFrame(self__.catch_block,self__.catch_exception,self__.finally_block,self__.continue_block,self__.prev,G__23576,self__.__extmap,self__.__hash));
|
||||
});
|
||||
|
||||
cljs.core.async.impl.ioc_helpers.ExceptionFrame.prototype.cljs$core$ICollection$_conj$arity$2 = (function (this__4390__auto__,entry__4391__auto__){
|
||||
var self__ = this;
|
||||
var this__4390__auto____$1 = this;
|
||||
if(cljs.core.vector_QMARK_.call(null,entry__4391__auto__)){
|
||||
return this__4390__auto____$1.cljs$core$IAssociative$_assoc$arity$3(null,cljs.core._nth.call(null,entry__4391__auto__,(0)),cljs.core._nth.call(null,entry__4391__auto__,(1)));
|
||||
} else {
|
||||
return cljs.core.reduce.call(null,cljs.core._conj,this__4390__auto____$1,entry__4391__auto__);
|
||||
}
|
||||
});
|
||||
|
||||
cljs.core.async.impl.ioc_helpers.ExceptionFrame.getBasis = (function (){
|
||||
return new cljs.core.PersistentVector(null, 5, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Symbol(null,"catch-block","catch-block",-1479223021,null),cljs.core.with_meta(new cljs.core.Symbol(null,"catch-exception","catch-exception",-356775268,null),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"tag","tag",-1290361223),new cljs.core.Symbol(null,"Class","Class",2064526977,null)], null)),new cljs.core.Symbol(null,"finally-block","finally-block",-1821453297,null),new cljs.core.Symbol(null,"continue-block","continue-block",-211516323,null),new cljs.core.Symbol(null,"prev","prev",43462301,null)], null);
|
||||
});
|
||||
|
||||
cljs.core.async.impl.ioc_helpers.ExceptionFrame.cljs$lang$type = true;
|
||||
|
||||
cljs.core.async.impl.ioc_helpers.ExceptionFrame.cljs$lang$ctorPrSeq = (function (this__4428__auto__){
|
||||
return (new cljs.core.List(null,"cljs.core.async.impl.ioc-helpers/ExceptionFrame",null,(1),null));
|
||||
});
|
||||
|
||||
cljs.core.async.impl.ioc_helpers.ExceptionFrame.cljs$lang$ctorPrWriter = (function (this__4428__auto__,writer__4429__auto__){
|
||||
return cljs.core._write.call(null,writer__4429__auto__,"cljs.core.async.impl.ioc-helpers/ExceptionFrame");
|
||||
});
|
||||
|
||||
/**
|
||||
* Positional factory function for cljs.core.async.impl.ioc-helpers/ExceptionFrame.
|
||||
*/
|
||||
cljs.core.async.impl.ioc_helpers.__GT_ExceptionFrame = (function cljs$core$async$impl$ioc_helpers$__GT_ExceptionFrame(catch_block,catch_exception,finally_block,continue_block,prev){
|
||||
return (new cljs.core.async.impl.ioc_helpers.ExceptionFrame(catch_block,catch_exception,finally_block,continue_block,prev,null,null,null));
|
||||
});
|
||||
|
||||
/**
|
||||
* Factory function for cljs.core.async.impl.ioc-helpers/ExceptionFrame, taking a map of keywords to field values.
|
||||
*/
|
||||
cljs.core.async.impl.ioc_helpers.map__GT_ExceptionFrame = (function cljs$core$async$impl$ioc_helpers$map__GT_ExceptionFrame(G__23580){
|
||||
var extmap__4424__auto__ = (function (){var G__23589 = cljs.core.dissoc.call(null,G__23580,new cljs.core.Keyword(null,"catch-block","catch-block",1175212748),new cljs.core.Keyword(null,"catch-exception","catch-exception",-1997306795),new cljs.core.Keyword(null,"finally-block","finally-block",832982472),new cljs.core.Keyword(null,"continue-block","continue-block",-1852047850),new cljs.core.Keyword(null,"prev","prev",-1597069226));
|
||||
if(cljs.core.record_QMARK_.call(null,G__23580)){
|
||||
return cljs.core.into.call(null,cljs.core.PersistentArrayMap.EMPTY,G__23589);
|
||||
} else {
|
||||
return G__23589;
|
||||
}
|
||||
})();
|
||||
return (new cljs.core.async.impl.ioc_helpers.ExceptionFrame(new cljs.core.Keyword(null,"catch-block","catch-block",1175212748).cljs$core$IFn$_invoke$arity$1(G__23580),new cljs.core.Keyword(null,"catch-exception","catch-exception",-1997306795).cljs$core$IFn$_invoke$arity$1(G__23580),new cljs.core.Keyword(null,"finally-block","finally-block",832982472).cljs$core$IFn$_invoke$arity$1(G__23580),new cljs.core.Keyword(null,"continue-block","continue-block",-1852047850).cljs$core$IFn$_invoke$arity$1(G__23580),new cljs.core.Keyword(null,"prev","prev",-1597069226).cljs$core$IFn$_invoke$arity$1(G__23580),null,cljs.core.not_empty.call(null,extmap__4424__auto__),null));
|
||||
});
|
||||
|
||||
cljs.core.async.impl.ioc_helpers.add_exception_frame = (function cljs$core$async$impl$ioc_helpers$add_exception_frame(state,catch_block,catch_exception,finally_block,continue_block){
|
||||
var statearr_23591 = state;
|
||||
(statearr_23591[(4)] = cljs.core.async.impl.ioc_helpers.__GT_ExceptionFrame.call(null,catch_block,catch_exception,finally_block,continue_block,cljs.core.async.impl.ioc_helpers.aget_object.call(null,state,(4))));
|
||||
|
||||
return statearr_23591;
|
||||
});
|
||||
cljs.core.async.impl.ioc_helpers.process_exception = (function cljs$core$async$impl$ioc_helpers$process_exception(state){
|
||||
while(true){
|
||||
var exception_frame = cljs.core.async.impl.ioc_helpers.aget_object.call(null,state,(4));
|
||||
var catch_block = new cljs.core.Keyword(null,"catch-block","catch-block",1175212748).cljs$core$IFn$_invoke$arity$1(exception_frame);
|
||||
var catch_exception = new cljs.core.Keyword(null,"catch-exception","catch-exception",-1997306795).cljs$core$IFn$_invoke$arity$1(exception_frame);
|
||||
var exception = cljs.core.async.impl.ioc_helpers.aget_object.call(null,state,(5));
|
||||
if(cljs.core.truth_((function (){var and__4120__auto__ = exception;
|
||||
if(cljs.core.truth_(and__4120__auto__)){
|
||||
return cljs.core.not.call(null,exception_frame);
|
||||
} else {
|
||||
return and__4120__auto__;
|
||||
}
|
||||
})())){
|
||||
throw exception;
|
||||
} else {
|
||||
if(cljs.core.truth_((function (){var and__4120__auto__ = exception;
|
||||
if(cljs.core.truth_(and__4120__auto__)){
|
||||
var and__4120__auto____$1 = catch_block;
|
||||
if(cljs.core.truth_(and__4120__auto____$1)){
|
||||
return ((cljs.core._EQ_.call(null,new cljs.core.Keyword(null,"default","default",-1987822328),catch_exception)) || ((exception instanceof catch_exception)));
|
||||
} else {
|
||||
return and__4120__auto____$1;
|
||||
}
|
||||
} else {
|
||||
return and__4120__auto__;
|
||||
}
|
||||
})())){
|
||||
var statearr_23592 = state;
|
||||
(statearr_23592[(1)] = catch_block);
|
||||
|
||||
(statearr_23592[(2)] = exception);
|
||||
|
||||
(statearr_23592[(5)] = null);
|
||||
|
||||
(statearr_23592[(4)] = cljs.core.assoc.call(null,exception_frame,new cljs.core.Keyword(null,"catch-block","catch-block",1175212748),null,new cljs.core.Keyword(null,"catch-exception","catch-exception",-1997306795),null));
|
||||
|
||||
return statearr_23592;
|
||||
} else {
|
||||
if(cljs.core.truth_((function (){var and__4120__auto__ = exception;
|
||||
if(cljs.core.truth_(and__4120__auto__)){
|
||||
return ((cljs.core.not.call(null,catch_block)) && (cljs.core.not.call(null,new cljs.core.Keyword(null,"finally-block","finally-block",832982472).cljs$core$IFn$_invoke$arity$1(exception_frame))));
|
||||
} else {
|
||||
return and__4120__auto__;
|
||||
}
|
||||
})())){
|
||||
var statearr_23593_23597 = state;
|
||||
(statearr_23593_23597[(4)] = new cljs.core.Keyword(null,"prev","prev",-1597069226).cljs$core$IFn$_invoke$arity$1(exception_frame));
|
||||
|
||||
|
||||
var G__23598 = state;
|
||||
state = G__23598;
|
||||
continue;
|
||||
} else {
|
||||
if(cljs.core.truth_((function (){var and__4120__auto__ = exception;
|
||||
if(cljs.core.truth_(and__4120__auto__)){
|
||||
var and__4120__auto____$1 = cljs.core.not.call(null,catch_block);
|
||||
if(and__4120__auto____$1){
|
||||
return new cljs.core.Keyword(null,"finally-block","finally-block",832982472).cljs$core$IFn$_invoke$arity$1(exception_frame);
|
||||
} else {
|
||||
return and__4120__auto____$1;
|
||||
}
|
||||
} else {
|
||||
return and__4120__auto__;
|
||||
}
|
||||
})())){
|
||||
var statearr_23594 = state;
|
||||
(statearr_23594[(1)] = new cljs.core.Keyword(null,"finally-block","finally-block",832982472).cljs$core$IFn$_invoke$arity$1(exception_frame));
|
||||
|
||||
(statearr_23594[(4)] = cljs.core.assoc.call(null,exception_frame,new cljs.core.Keyword(null,"finally-block","finally-block",832982472),null));
|
||||
|
||||
return statearr_23594;
|
||||
} else {
|
||||
if(cljs.core.truth_((function (){var and__4120__auto__ = cljs.core.not.call(null,exception);
|
||||
if(and__4120__auto__){
|
||||
return new cljs.core.Keyword(null,"finally-block","finally-block",832982472).cljs$core$IFn$_invoke$arity$1(exception_frame);
|
||||
} else {
|
||||
return and__4120__auto__;
|
||||
}
|
||||
})())){
|
||||
var statearr_23595 = state;
|
||||
(statearr_23595[(1)] = new cljs.core.Keyword(null,"finally-block","finally-block",832982472).cljs$core$IFn$_invoke$arity$1(exception_frame));
|
||||
|
||||
(statearr_23595[(4)] = cljs.core.assoc.call(null,exception_frame,new cljs.core.Keyword(null,"finally-block","finally-block",832982472),null));
|
||||
|
||||
return statearr_23595;
|
||||
} else {
|
||||
if(((cljs.core.not.call(null,exception)) && (cljs.core.not.call(null,new cljs.core.Keyword(null,"finally-block","finally-block",832982472).cljs$core$IFn$_invoke$arity$1(exception_frame))))){
|
||||
var statearr_23596 = state;
|
||||
(statearr_23596[(1)] = new cljs.core.Keyword(null,"continue-block","continue-block",-1852047850).cljs$core$IFn$_invoke$arity$1(exception_frame));
|
||||
|
||||
(statearr_23596[(4)] = new cljs.core.Keyword(null,"prev","prev",-1597069226).cljs$core$IFn$_invoke$arity$1(exception_frame));
|
||||
|
||||
return statearr_23596;
|
||||
} else {
|
||||
throw (new Error("No matching clause"));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
//# sourceMappingURL=ioc_helpers.js.map
|
||||
File diff suppressed because one or more lines are too long
|
|
@ -0,0 +1,43 @@
|
|||
;; Copyright (c) Rich Hickey and contributors. All rights reserved.
|
||||
;; The use and distribution terms for this software are covered by the
|
||||
;; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
|
||||
;; which can be found in the file epl-v10.html at the root of this distribution.
|
||||
;; By using this software in any fashion, you are agreeing to be bound by
|
||||
;; the terms of this license.
|
||||
;; You must not remove this notice, or any other, from this software.
|
||||
|
||||
(ns cljs.core.async.impl.protocols)
|
||||
|
||||
(def ^:const MAX-QUEUE-SIZE 1024)
|
||||
|
||||
(defprotocol ReadPort
|
||||
(take! [port fn1-handler] "derefable val if taken, nil if take was enqueued"))
|
||||
|
||||
(defprotocol WritePort
|
||||
(put! [port val fn1-handler] "derefable boolean (false if already closed) if handled, nil if put was enqueued.
|
||||
Must throw on nil val."))
|
||||
|
||||
(defprotocol Channel
|
||||
(close! [chan])
|
||||
(closed? [chan]))
|
||||
|
||||
(defprotocol Handler
|
||||
(active? [h] "returns true if has callback. Must work w/o lock")
|
||||
(blockable? [h] "returns true if this handler may be blocked, otherwise it must not block")
|
||||
#_(lock-id [h] "a unique id for lock acquisition order, 0 if no lock")
|
||||
(commit [h] "commit to fulfilling its end of the transfer, returns cb. Must be called within lock"))
|
||||
|
||||
(defprotocol Buffer
|
||||
(full? [b] "returns true if buffer cannot accept put")
|
||||
(remove! [b] "remove and return next item from buffer, called under chan mutex")
|
||||
(add!* [b itm] "if room, add item to the buffer, returns b, called under chan mutex")
|
||||
(close-buf! [b] "called on chan closed under chan mutex, return ignored"))
|
||||
|
||||
(defn add!
|
||||
([b] b)
|
||||
([b itm]
|
||||
(assert (not (nil? itm)))
|
||||
(add!* b itm)))
|
||||
|
||||
;; Defines a buffer that will never block (return true to full?)
|
||||
(defprotocol UnblockingBuffer)
|
||||
File diff suppressed because one or more lines are too long
|
|
@ -0,0 +1,311 @@
|
|||
// Compiled by ClojureScript 1.10.520 {}
|
||||
goog.provide('cljs.core.async.impl.protocols');
|
||||
goog.require('cljs.core');
|
||||
cljs.core.async.impl.protocols.MAX_QUEUE_SIZE = (1024);
|
||||
|
||||
/**
|
||||
* @interface
|
||||
*/
|
||||
cljs.core.async.impl.protocols.ReadPort = function(){};
|
||||
|
||||
/**
|
||||
* derefable val if taken, nil if take was enqueued
|
||||
*/
|
||||
cljs.core.async.impl.protocols.take_BANG_ = (function cljs$core$async$impl$protocols$take_BANG_(port,fn1_handler){
|
||||
if((((!((port == null)))) && ((!((port.cljs$core$async$impl$protocols$ReadPort$take_BANG_$arity$2 == null)))))){
|
||||
return port.cljs$core$async$impl$protocols$ReadPort$take_BANG_$arity$2(port,fn1_handler);
|
||||
} else {
|
||||
var x__4433__auto__ = (((port == null))?null:port);
|
||||
var m__4434__auto__ = (cljs.core.async.impl.protocols.take_BANG_[goog.typeOf(x__4433__auto__)]);
|
||||
if((!((m__4434__auto__ == null)))){
|
||||
return m__4434__auto__.call(null,port,fn1_handler);
|
||||
} else {
|
||||
var m__4431__auto__ = (cljs.core.async.impl.protocols.take_BANG_["_"]);
|
||||
if((!((m__4431__auto__ == null)))){
|
||||
return m__4431__auto__.call(null,port,fn1_handler);
|
||||
} else {
|
||||
throw cljs.core.missing_protocol.call(null,"ReadPort.take!",port);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* @interface
|
||||
*/
|
||||
cljs.core.async.impl.protocols.WritePort = function(){};
|
||||
|
||||
/**
|
||||
* derefable boolean (false if already closed) if handled, nil if put was enqueued.
|
||||
* Must throw on nil val.
|
||||
*/
|
||||
cljs.core.async.impl.protocols.put_BANG_ = (function cljs$core$async$impl$protocols$put_BANG_(port,val,fn1_handler){
|
||||
if((((!((port == null)))) && ((!((port.cljs$core$async$impl$protocols$WritePort$put_BANG_$arity$3 == null)))))){
|
||||
return port.cljs$core$async$impl$protocols$WritePort$put_BANG_$arity$3(port,val,fn1_handler);
|
||||
} else {
|
||||
var x__4433__auto__ = (((port == null))?null:port);
|
||||
var m__4434__auto__ = (cljs.core.async.impl.protocols.put_BANG_[goog.typeOf(x__4433__auto__)]);
|
||||
if((!((m__4434__auto__ == null)))){
|
||||
return m__4434__auto__.call(null,port,val,fn1_handler);
|
||||
} else {
|
||||
var m__4431__auto__ = (cljs.core.async.impl.protocols.put_BANG_["_"]);
|
||||
if((!((m__4431__auto__ == null)))){
|
||||
return m__4431__auto__.call(null,port,val,fn1_handler);
|
||||
} else {
|
||||
throw cljs.core.missing_protocol.call(null,"WritePort.put!",port);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* @interface
|
||||
*/
|
||||
cljs.core.async.impl.protocols.Channel = function(){};
|
||||
|
||||
cljs.core.async.impl.protocols.close_BANG_ = (function cljs$core$async$impl$protocols$close_BANG_(chan){
|
||||
if((((!((chan == null)))) && ((!((chan.cljs$core$async$impl$protocols$Channel$close_BANG_$arity$1 == null)))))){
|
||||
return chan.cljs$core$async$impl$protocols$Channel$close_BANG_$arity$1(chan);
|
||||
} else {
|
||||
var x__4433__auto__ = (((chan == null))?null:chan);
|
||||
var m__4434__auto__ = (cljs.core.async.impl.protocols.close_BANG_[goog.typeOf(x__4433__auto__)]);
|
||||
if((!((m__4434__auto__ == null)))){
|
||||
return m__4434__auto__.call(null,chan);
|
||||
} else {
|
||||
var m__4431__auto__ = (cljs.core.async.impl.protocols.close_BANG_["_"]);
|
||||
if((!((m__4431__auto__ == null)))){
|
||||
return m__4431__auto__.call(null,chan);
|
||||
} else {
|
||||
throw cljs.core.missing_protocol.call(null,"Channel.close!",chan);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
cljs.core.async.impl.protocols.closed_QMARK_ = (function cljs$core$async$impl$protocols$closed_QMARK_(chan){
|
||||
if((((!((chan == null)))) && ((!((chan.cljs$core$async$impl$protocols$Channel$closed_QMARK_$arity$1 == null)))))){
|
||||
return chan.cljs$core$async$impl$protocols$Channel$closed_QMARK_$arity$1(chan);
|
||||
} else {
|
||||
var x__4433__auto__ = (((chan == null))?null:chan);
|
||||
var m__4434__auto__ = (cljs.core.async.impl.protocols.closed_QMARK_[goog.typeOf(x__4433__auto__)]);
|
||||
if((!((m__4434__auto__ == null)))){
|
||||
return m__4434__auto__.call(null,chan);
|
||||
} else {
|
||||
var m__4431__auto__ = (cljs.core.async.impl.protocols.closed_QMARK_["_"]);
|
||||
if((!((m__4431__auto__ == null)))){
|
||||
return m__4431__auto__.call(null,chan);
|
||||
} else {
|
||||
throw cljs.core.missing_protocol.call(null,"Channel.closed?",chan);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* @interface
|
||||
*/
|
||||
cljs.core.async.impl.protocols.Handler = function(){};
|
||||
|
||||
/**
|
||||
* returns true if has callback. Must work w/o lock
|
||||
*/
|
||||
cljs.core.async.impl.protocols.active_QMARK_ = (function cljs$core$async$impl$protocols$active_QMARK_(h){
|
||||
if((((!((h == null)))) && ((!((h.cljs$core$async$impl$protocols$Handler$active_QMARK_$arity$1 == null)))))){
|
||||
return h.cljs$core$async$impl$protocols$Handler$active_QMARK_$arity$1(h);
|
||||
} else {
|
||||
var x__4433__auto__ = (((h == null))?null:h);
|
||||
var m__4434__auto__ = (cljs.core.async.impl.protocols.active_QMARK_[goog.typeOf(x__4433__auto__)]);
|
||||
if((!((m__4434__auto__ == null)))){
|
||||
return m__4434__auto__.call(null,h);
|
||||
} else {
|
||||
var m__4431__auto__ = (cljs.core.async.impl.protocols.active_QMARK_["_"]);
|
||||
if((!((m__4431__auto__ == null)))){
|
||||
return m__4431__auto__.call(null,h);
|
||||
} else {
|
||||
throw cljs.core.missing_protocol.call(null,"Handler.active?",h);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* returns true if this handler may be blocked, otherwise it must not block
|
||||
*/
|
||||
cljs.core.async.impl.protocols.blockable_QMARK_ = (function cljs$core$async$impl$protocols$blockable_QMARK_(h){
|
||||
if((((!((h == null)))) && ((!((h.cljs$core$async$impl$protocols$Handler$blockable_QMARK_$arity$1 == null)))))){
|
||||
return h.cljs$core$async$impl$protocols$Handler$blockable_QMARK_$arity$1(h);
|
||||
} else {
|
||||
var x__4433__auto__ = (((h == null))?null:h);
|
||||
var m__4434__auto__ = (cljs.core.async.impl.protocols.blockable_QMARK_[goog.typeOf(x__4433__auto__)]);
|
||||
if((!((m__4434__auto__ == null)))){
|
||||
return m__4434__auto__.call(null,h);
|
||||
} else {
|
||||
var m__4431__auto__ = (cljs.core.async.impl.protocols.blockable_QMARK_["_"]);
|
||||
if((!((m__4431__auto__ == null)))){
|
||||
return m__4431__auto__.call(null,h);
|
||||
} else {
|
||||
throw cljs.core.missing_protocol.call(null,"Handler.blockable?",h);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* commit to fulfilling its end of the transfer, returns cb. Must be called within lock
|
||||
*/
|
||||
cljs.core.async.impl.protocols.commit = (function cljs$core$async$impl$protocols$commit(h){
|
||||
if((((!((h == null)))) && ((!((h.cljs$core$async$impl$protocols$Handler$commit$arity$1 == null)))))){
|
||||
return h.cljs$core$async$impl$protocols$Handler$commit$arity$1(h);
|
||||
} else {
|
||||
var x__4433__auto__ = (((h == null))?null:h);
|
||||
var m__4434__auto__ = (cljs.core.async.impl.protocols.commit[goog.typeOf(x__4433__auto__)]);
|
||||
if((!((m__4434__auto__ == null)))){
|
||||
return m__4434__auto__.call(null,h);
|
||||
} else {
|
||||
var m__4431__auto__ = (cljs.core.async.impl.protocols.commit["_"]);
|
||||
if((!((m__4431__auto__ == null)))){
|
||||
return m__4431__auto__.call(null,h);
|
||||
} else {
|
||||
throw cljs.core.missing_protocol.call(null,"Handler.commit",h);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* @interface
|
||||
*/
|
||||
cljs.core.async.impl.protocols.Buffer = function(){};
|
||||
|
||||
/**
|
||||
* returns true if buffer cannot accept put
|
||||
*/
|
||||
cljs.core.async.impl.protocols.full_QMARK_ = (function cljs$core$async$impl$protocols$full_QMARK_(b){
|
||||
if((((!((b == null)))) && ((!((b.cljs$core$async$impl$protocols$Buffer$full_QMARK_$arity$1 == null)))))){
|
||||
return b.cljs$core$async$impl$protocols$Buffer$full_QMARK_$arity$1(b);
|
||||
} else {
|
||||
var x__4433__auto__ = (((b == null))?null:b);
|
||||
var m__4434__auto__ = (cljs.core.async.impl.protocols.full_QMARK_[goog.typeOf(x__4433__auto__)]);
|
||||
if((!((m__4434__auto__ == null)))){
|
||||
return m__4434__auto__.call(null,b);
|
||||
} else {
|
||||
var m__4431__auto__ = (cljs.core.async.impl.protocols.full_QMARK_["_"]);
|
||||
if((!((m__4431__auto__ == null)))){
|
||||
return m__4431__auto__.call(null,b);
|
||||
} else {
|
||||
throw cljs.core.missing_protocol.call(null,"Buffer.full?",b);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* remove and return next item from buffer, called under chan mutex
|
||||
*/
|
||||
cljs.core.async.impl.protocols.remove_BANG_ = (function cljs$core$async$impl$protocols$remove_BANG_(b){
|
||||
if((((!((b == null)))) && ((!((b.cljs$core$async$impl$protocols$Buffer$remove_BANG_$arity$1 == null)))))){
|
||||
return b.cljs$core$async$impl$protocols$Buffer$remove_BANG_$arity$1(b);
|
||||
} else {
|
||||
var x__4433__auto__ = (((b == null))?null:b);
|
||||
var m__4434__auto__ = (cljs.core.async.impl.protocols.remove_BANG_[goog.typeOf(x__4433__auto__)]);
|
||||
if((!((m__4434__auto__ == null)))){
|
||||
return m__4434__auto__.call(null,b);
|
||||
} else {
|
||||
var m__4431__auto__ = (cljs.core.async.impl.protocols.remove_BANG_["_"]);
|
||||
if((!((m__4431__auto__ == null)))){
|
||||
return m__4431__auto__.call(null,b);
|
||||
} else {
|
||||
throw cljs.core.missing_protocol.call(null,"Buffer.remove!",b);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* if room, add item to the buffer, returns b, called under chan mutex
|
||||
*/
|
||||
cljs.core.async.impl.protocols.add_BANG__STAR_ = (function cljs$core$async$impl$protocols$add_BANG__STAR_(b,itm){
|
||||
if((((!((b == null)))) && ((!((b.cljs$core$async$impl$protocols$Buffer$add_BANG__STAR_$arity$2 == null)))))){
|
||||
return b.cljs$core$async$impl$protocols$Buffer$add_BANG__STAR_$arity$2(b,itm);
|
||||
} else {
|
||||
var x__4433__auto__ = (((b == null))?null:b);
|
||||
var m__4434__auto__ = (cljs.core.async.impl.protocols.add_BANG__STAR_[goog.typeOf(x__4433__auto__)]);
|
||||
if((!((m__4434__auto__ == null)))){
|
||||
return m__4434__auto__.call(null,b,itm);
|
||||
} else {
|
||||
var m__4431__auto__ = (cljs.core.async.impl.protocols.add_BANG__STAR_["_"]);
|
||||
if((!((m__4431__auto__ == null)))){
|
||||
return m__4431__auto__.call(null,b,itm);
|
||||
} else {
|
||||
throw cljs.core.missing_protocol.call(null,"Buffer.add!*",b);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* called on chan closed under chan mutex, return ignored
|
||||
*/
|
||||
cljs.core.async.impl.protocols.close_buf_BANG_ = (function cljs$core$async$impl$protocols$close_buf_BANG_(b){
|
||||
if((((!((b == null)))) && ((!((b.cljs$core$async$impl$protocols$Buffer$close_buf_BANG_$arity$1 == null)))))){
|
||||
return b.cljs$core$async$impl$protocols$Buffer$close_buf_BANG_$arity$1(b);
|
||||
} else {
|
||||
var x__4433__auto__ = (((b == null))?null:b);
|
||||
var m__4434__auto__ = (cljs.core.async.impl.protocols.close_buf_BANG_[goog.typeOf(x__4433__auto__)]);
|
||||
if((!((m__4434__auto__ == null)))){
|
||||
return m__4434__auto__.call(null,b);
|
||||
} else {
|
||||
var m__4431__auto__ = (cljs.core.async.impl.protocols.close_buf_BANG_["_"]);
|
||||
if((!((m__4431__auto__ == null)))){
|
||||
return m__4431__auto__.call(null,b);
|
||||
} else {
|
||||
throw cljs.core.missing_protocol.call(null,"Buffer.close-buf!",b);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
cljs.core.async.impl.protocols.add_BANG_ = (function cljs$core$async$impl$protocols$add_BANG_(var_args){
|
||||
var G__21526 = arguments.length;
|
||||
switch (G__21526) {
|
||||
case 1:
|
||||
return cljs.core.async.impl.protocols.add_BANG_.cljs$core$IFn$_invoke$arity$1((arguments[(0)]));
|
||||
|
||||
break;
|
||||
case 2:
|
||||
return cljs.core.async.impl.protocols.add_BANG_.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)]));
|
||||
|
||||
break;
|
||||
default:
|
||||
throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
cljs.core.async.impl.protocols.add_BANG_.cljs$core$IFn$_invoke$arity$1 = (function (b){
|
||||
return b;
|
||||
});
|
||||
|
||||
cljs.core.async.impl.protocols.add_BANG_.cljs$core$IFn$_invoke$arity$2 = (function (b,itm){
|
||||
if((!((itm == null)))){
|
||||
} else {
|
||||
throw (new Error("Assert failed: (not (nil? itm))"));
|
||||
}
|
||||
|
||||
return cljs.core.async.impl.protocols.add_BANG__STAR_.call(null,b,itm);
|
||||
});
|
||||
|
||||
cljs.core.async.impl.protocols.add_BANG_.cljs$lang$maxFixedArity = 2;
|
||||
|
||||
|
||||
/**
|
||||
* @interface
|
||||
*/
|
||||
cljs.core.async.impl.protocols.UnblockingBuffer = function(){};
|
||||
|
||||
|
||||
//# sourceMappingURL=protocols.js.map
|
||||
File diff suppressed because one or more lines are too long
|
|
@ -0,0 +1,172 @@
|
|||
;; Copyright (c) Rich Hickey and contributors. All rights reserved.
|
||||
;; The use and distribution terms for this software are covered by the
|
||||
;; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
|
||||
;; which can be found in the file epl-v10.html at the root of this distribution.
|
||||
;; By using this software in any fashion, you are agreeing to be bound by
|
||||
;; the terms of this license.
|
||||
;; You must not remove this notice, or any other, from this software.
|
||||
|
||||
(ns cljs.core.async.impl.timers
|
||||
(:require [cljs.core.async.impl.protocols :as impl]
|
||||
[cljs.core.async.impl.channels :as channels]
|
||||
[cljs.core.async.impl.dispatch :as dispatch]))
|
||||
|
||||
(def MAX_LEVEL 15) ;; 16 levels
|
||||
(def P (/ 1 2))
|
||||
|
||||
(defn random-level
|
||||
([] (random-level 0))
|
||||
([level]
|
||||
(if (and (< (.random js/Math) P)
|
||||
(< level MAX_LEVEL))
|
||||
(recur (inc level))
|
||||
level)))
|
||||
|
||||
(deftype SkipListNode [key ^:mutable val forward]
|
||||
ISeqable
|
||||
(-seq [coll]
|
||||
(list key val))
|
||||
|
||||
IPrintWithWriter
|
||||
(-pr-writer [coll writer opts]
|
||||
(pr-sequential-writer writer pr-writer "[" " " "]" opts coll)))
|
||||
|
||||
(defn skip-list-node
|
||||
([level] (skip-list-node nil nil level))
|
||||
([k v level]
|
||||
(let [arr (make-array (inc level))]
|
||||
(loop [i 0]
|
||||
(when (< i (alength arr))
|
||||
(aset arr i nil)
|
||||
(recur (inc i))))
|
||||
(SkipListNode. k v arr))))
|
||||
|
||||
(defn least-greater-node
|
||||
([x k level] (least-greater-node x k level nil))
|
||||
([x k level update]
|
||||
(if-not (neg? level)
|
||||
(let [x (loop [x x]
|
||||
(if-let [x' (when (< level (alength (.-forward x)))
|
||||
(aget (.-forward x) level))]
|
||||
(if (< (.-key x') k)
|
||||
(recur x')
|
||||
x)
|
||||
x))]
|
||||
(when-not (nil? update)
|
||||
(aset update level x))
|
||||
(recur x k (dec level) update))
|
||||
x)))
|
||||
|
||||
(deftype SkipList [header ^:mutable level]
|
||||
Object
|
||||
(put [coll k v]
|
||||
(let [update (make-array MAX_LEVEL)
|
||||
x (least-greater-node header k level update)
|
||||
x (aget (.-forward x) 0)]
|
||||
(if (and (not (nil? x)) (== (.-key x) k))
|
||||
(set! (.-val x) v)
|
||||
(let [new-level (random-level)]
|
||||
(when (> new-level level)
|
||||
(loop [i (inc level)]
|
||||
(when (<= i (inc new-level))
|
||||
(aset update i header)
|
||||
(recur (inc i))))
|
||||
(set! level new-level))
|
||||
(let [x (skip-list-node k v (make-array new-level))]
|
||||
(loop [i 0]
|
||||
(when (<= i level)
|
||||
(let [links (.-forward (aget update i))]
|
||||
(aset (.-forward x) i (aget links i))
|
||||
(aset links i x)))))))))
|
||||
|
||||
(remove [coll k]
|
||||
(let [update (make-array MAX_LEVEL)
|
||||
x (least-greater-node header k level update)
|
||||
x (when-not (zero? (alength (.-forward x)))
|
||||
(aget (.-forward x) 0))]
|
||||
(when (and (not (nil? x)) (== (.-key x) k))
|
||||
(loop [i 0]
|
||||
(when (<= i level)
|
||||
(let [links (.-forward (aget update i))]
|
||||
(if (identical? x (when (< i (alength links))
|
||||
(aget links i)))
|
||||
(do
|
||||
(aset links i (aget (.-forward x) i))
|
||||
(recur (inc i)))
|
||||
(recur (inc i))))))
|
||||
(while (and (< 0 level (alength (.-forward header)))
|
||||
(nil? (aget (.-forward header) level)))
|
||||
(set! level (dec level))))))
|
||||
|
||||
(ceilingEntry [coll k]
|
||||
(loop [x header level level]
|
||||
(if-not (neg? level)
|
||||
(let [nx (loop [x x]
|
||||
(let [x' (when (< level (alength (.-forward x)))
|
||||
(aget (.-forward x) level))]
|
||||
(when-not (nil? x')
|
||||
(if (>= (.-key x') k)
|
||||
x'
|
||||
(recur x')))))]
|
||||
(if-not (nil? nx)
|
||||
(recur nx (dec level))
|
||||
(recur x (dec level))))
|
||||
(when-not (identical? x header)
|
||||
x))))
|
||||
|
||||
(floorEntry [coll k]
|
||||
(loop [x header level level]
|
||||
(if-not (neg? level)
|
||||
(let [nx (loop [x x]
|
||||
(let [x' (when (< level (alength (.-forward x)))
|
||||
(aget (.-forward x) level))]
|
||||
(if-not (nil? x')
|
||||
(if (> (.-key x') k)
|
||||
x
|
||||
(recur x'))
|
||||
(when (zero? level)
|
||||
x))))]
|
||||
(if nx
|
||||
(recur nx (dec level))
|
||||
(recur x (dec level))))
|
||||
(when-not (identical? x header)
|
||||
x))))
|
||||
|
||||
ISeqable
|
||||
(-seq [coll]
|
||||
(letfn [(iter [node]
|
||||
(lazy-seq
|
||||
(when-not (nil? node)
|
||||
(cons [(.-key node) (.-val node)]
|
||||
(iter (aget (.-forward node) 0))))))]
|
||||
(iter (aget (.-forward header) 0))))
|
||||
|
||||
IPrintWithWriter
|
||||
(-pr-writer [coll writer opts]
|
||||
(let [pr-pair (fn [keyval]
|
||||
(pr-sequential-writer writer pr-writer "" " " "" opts keyval))]
|
||||
(pr-sequential-writer writer pr-pair "{" ", " "}" opts coll))))
|
||||
|
||||
(defn skip-list []
|
||||
(SkipList. (skip-list-node 0) 0))
|
||||
|
||||
(def timeouts-map (skip-list))
|
||||
|
||||
(def TIMEOUT_RESOLUTION_MS 10)
|
||||
|
||||
(defn timeout
|
||||
"returns a channel that will close after msecs"
|
||||
[msecs]
|
||||
(let [timeout (+ (.valueOf (js/Date.)) msecs)
|
||||
me (.ceilingEntry timeouts-map timeout)]
|
||||
(or (when (and me (< (.-key me) (+ timeout TIMEOUT_RESOLUTION_MS)))
|
||||
(.-val me))
|
||||
(let [timeout-channel (channels/chan nil)]
|
||||
(.put timeouts-map timeout timeout-channel)
|
||||
(dispatch/queue-delay
|
||||
(fn []
|
||||
(.remove timeouts-map timeout)
|
||||
(impl/close! timeout-channel))
|
||||
msecs)
|
||||
timeout-channel))))
|
||||
|
||||
File diff suppressed because one or more lines are too long
|
|
@ -0,0 +1,479 @@
|
|||
// Compiled by ClojureScript 1.10.520 {}
|
||||
goog.provide('cljs.core.async.impl.timers');
|
||||
goog.require('cljs.core');
|
||||
goog.require('cljs.core.async.impl.protocols');
|
||||
goog.require('cljs.core.async.impl.channels');
|
||||
goog.require('cljs.core.async.impl.dispatch');
|
||||
cljs.core.async.impl.timers.MAX_LEVEL = (15);
|
||||
cljs.core.async.impl.timers.P = ((1) / (2));
|
||||
cljs.core.async.impl.timers.random_level = (function cljs$core$async$impl$timers$random_level(var_args){
|
||||
var G__23602 = arguments.length;
|
||||
switch (G__23602) {
|
||||
case 0:
|
||||
return cljs.core.async.impl.timers.random_level.cljs$core$IFn$_invoke$arity$0();
|
||||
|
||||
break;
|
||||
case 1:
|
||||
return cljs.core.async.impl.timers.random_level.cljs$core$IFn$_invoke$arity$1((arguments[(0)]));
|
||||
|
||||
break;
|
||||
default:
|
||||
throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
cljs.core.async.impl.timers.random_level.cljs$core$IFn$_invoke$arity$0 = (function (){
|
||||
return cljs.core.async.impl.timers.random_level.call(null,(0));
|
||||
});
|
||||
|
||||
cljs.core.async.impl.timers.random_level.cljs$core$IFn$_invoke$arity$1 = (function (level){
|
||||
while(true){
|
||||
if((((Math.random() < cljs.core.async.impl.timers.P)) && ((level < cljs.core.async.impl.timers.MAX_LEVEL)))){
|
||||
var G__23604 = (level + (1));
|
||||
level = G__23604;
|
||||
continue;
|
||||
} else {
|
||||
return level;
|
||||
}
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
cljs.core.async.impl.timers.random_level.cljs$lang$maxFixedArity = 1;
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @implements {cljs.core.ISeqable}
|
||||
* @implements {cljs.core.IPrintWithWriter}
|
||||
*/
|
||||
cljs.core.async.impl.timers.SkipListNode = (function (key,val,forward){
|
||||
this.key = key;
|
||||
this.val = val;
|
||||
this.forward = forward;
|
||||
this.cljs$lang$protocol_mask$partition0$ = 2155872256;
|
||||
this.cljs$lang$protocol_mask$partition1$ = 0;
|
||||
});
|
||||
cljs.core.async.impl.timers.SkipListNode.prototype.cljs$core$ISeqable$_seq$arity$1 = (function (coll){
|
||||
var self__ = this;
|
||||
var coll__$1 = this;
|
||||
return (new cljs.core.List(null,self__.key,(new cljs.core.List(null,self__.val,null,(1),null)),(2),null));
|
||||
});
|
||||
|
||||
cljs.core.async.impl.timers.SkipListNode.prototype.cljs$core$IPrintWithWriter$_pr_writer$arity$3 = (function (coll,writer,opts){
|
||||
var self__ = this;
|
||||
var coll__$1 = this;
|
||||
return cljs.core.pr_sequential_writer.call(null,writer,cljs.core.pr_writer,"["," ","]",opts,coll__$1);
|
||||
});
|
||||
|
||||
cljs.core.async.impl.timers.SkipListNode.getBasis = (function (){
|
||||
return new cljs.core.PersistentVector(null, 3, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Symbol(null,"key","key",124488940,null),cljs.core.with_meta(new cljs.core.Symbol(null,"val","val",1769233139,null),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"mutable","mutable",875778266),true], null)),new cljs.core.Symbol(null,"forward","forward",1083186224,null)], null);
|
||||
});
|
||||
|
||||
cljs.core.async.impl.timers.SkipListNode.cljs$lang$type = true;
|
||||
|
||||
cljs.core.async.impl.timers.SkipListNode.cljs$lang$ctorStr = "cljs.core.async.impl.timers/SkipListNode";
|
||||
|
||||
cljs.core.async.impl.timers.SkipListNode.cljs$lang$ctorPrWriter = (function (this__4374__auto__,writer__4375__auto__,opt__4376__auto__){
|
||||
return cljs.core._write.call(null,writer__4375__auto__,"cljs.core.async.impl.timers/SkipListNode");
|
||||
});
|
||||
|
||||
/**
|
||||
* Positional factory function for cljs.core.async.impl.timers/SkipListNode.
|
||||
*/
|
||||
cljs.core.async.impl.timers.__GT_SkipListNode = (function cljs$core$async$impl$timers$__GT_SkipListNode(key,val,forward){
|
||||
return (new cljs.core.async.impl.timers.SkipListNode(key,val,forward));
|
||||
});
|
||||
|
||||
cljs.core.async.impl.timers.skip_list_node = (function cljs$core$async$impl$timers$skip_list_node(var_args){
|
||||
var G__23606 = arguments.length;
|
||||
switch (G__23606) {
|
||||
case 1:
|
||||
return cljs.core.async.impl.timers.skip_list_node.cljs$core$IFn$_invoke$arity$1((arguments[(0)]));
|
||||
|
||||
break;
|
||||
case 3:
|
||||
return cljs.core.async.impl.timers.skip_list_node.cljs$core$IFn$_invoke$arity$3((arguments[(0)]),(arguments[(1)]),(arguments[(2)]));
|
||||
|
||||
break;
|
||||
default:
|
||||
throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
cljs.core.async.impl.timers.skip_list_node.cljs$core$IFn$_invoke$arity$1 = (function (level){
|
||||
return cljs.core.async.impl.timers.skip_list_node.call(null,null,null,level);
|
||||
});
|
||||
|
||||
cljs.core.async.impl.timers.skip_list_node.cljs$core$IFn$_invoke$arity$3 = (function (k,v,level){
|
||||
var arr = (new Array((level + (1))));
|
||||
var i_23608 = (0);
|
||||
while(true){
|
||||
if((i_23608 < arr.length)){
|
||||
(arr[i_23608] = null);
|
||||
|
||||
var G__23609 = (i_23608 + (1));
|
||||
i_23608 = G__23609;
|
||||
continue;
|
||||
} else {
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return (new cljs.core.async.impl.timers.SkipListNode(k,v,arr));
|
||||
});
|
||||
|
||||
cljs.core.async.impl.timers.skip_list_node.cljs$lang$maxFixedArity = 3;
|
||||
|
||||
cljs.core.async.impl.timers.least_greater_node = (function cljs$core$async$impl$timers$least_greater_node(var_args){
|
||||
var G__23611 = arguments.length;
|
||||
switch (G__23611) {
|
||||
case 3:
|
||||
return cljs.core.async.impl.timers.least_greater_node.cljs$core$IFn$_invoke$arity$3((arguments[(0)]),(arguments[(1)]),(arguments[(2)]));
|
||||
|
||||
break;
|
||||
case 4:
|
||||
return cljs.core.async.impl.timers.least_greater_node.cljs$core$IFn$_invoke$arity$4((arguments[(0)]),(arguments[(1)]),(arguments[(2)]),(arguments[(3)]));
|
||||
|
||||
break;
|
||||
default:
|
||||
throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
cljs.core.async.impl.timers.least_greater_node.cljs$core$IFn$_invoke$arity$3 = (function (x,k,level){
|
||||
return cljs.core.async.impl.timers.least_greater_node.call(null,x,k,level,null);
|
||||
});
|
||||
|
||||
cljs.core.async.impl.timers.least_greater_node.cljs$core$IFn$_invoke$arity$4 = (function (x,k,level,update){
|
||||
while(true){
|
||||
if((!((level < (0))))){
|
||||
var x__$1 = (function (){var x__$1 = x;
|
||||
while(true){
|
||||
var temp__5718__auto__ = (((level < x__$1.forward.length))?(x__$1.forward[level]):null);
|
||||
if(cljs.core.truth_(temp__5718__auto__)){
|
||||
var x_SINGLEQUOTE_ = temp__5718__auto__;
|
||||
if((x_SINGLEQUOTE_.key < k)){
|
||||
var G__23613 = x_SINGLEQUOTE_;
|
||||
x__$1 = G__23613;
|
||||
continue;
|
||||
} else {
|
||||
return x__$1;
|
||||
}
|
||||
} else {
|
||||
return x__$1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
})();
|
||||
if((update == null)){
|
||||
} else {
|
||||
(update[level] = x__$1);
|
||||
}
|
||||
|
||||
var G__23614 = x__$1;
|
||||
var G__23615 = k;
|
||||
var G__23616 = (level - (1));
|
||||
var G__23617 = update;
|
||||
x = G__23614;
|
||||
k = G__23615;
|
||||
level = G__23616;
|
||||
update = G__23617;
|
||||
continue;
|
||||
} else {
|
||||
return x;
|
||||
}
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
cljs.core.async.impl.timers.least_greater_node.cljs$lang$maxFixedArity = 4;
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @implements {cljs.core.async.impl.timers.Object}
|
||||
* @implements {cljs.core.ISeqable}
|
||||
* @implements {cljs.core.IPrintWithWriter}
|
||||
*/
|
||||
cljs.core.async.impl.timers.SkipList = (function (header,level){
|
||||
this.header = header;
|
||||
this.level = level;
|
||||
this.cljs$lang$protocol_mask$partition0$ = 2155872256;
|
||||
this.cljs$lang$protocol_mask$partition1$ = 0;
|
||||
});
|
||||
cljs.core.async.impl.timers.SkipList.prototype.put = (function (k,v){
|
||||
var self__ = this;
|
||||
var coll = this;
|
||||
var update = (new Array(cljs.core.async.impl.timers.MAX_LEVEL));
|
||||
var x = cljs.core.async.impl.timers.least_greater_node.call(null,self__.header,k,self__.level,update);
|
||||
var x__$1 = (x.forward[(0)]);
|
||||
if((((!((x__$1 == null)))) && ((x__$1.key === k)))){
|
||||
return x__$1.val = v;
|
||||
} else {
|
||||
var new_level = cljs.core.async.impl.timers.random_level.call(null);
|
||||
if((new_level > self__.level)){
|
||||
var i_23618 = (self__.level + (1));
|
||||
while(true){
|
||||
if((i_23618 <= (new_level + (1)))){
|
||||
(update[i_23618] = self__.header);
|
||||
|
||||
var G__23619 = (i_23618 + (1));
|
||||
i_23618 = G__23619;
|
||||
continue;
|
||||
} else {
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
self__.level = new_level;
|
||||
} else {
|
||||
}
|
||||
|
||||
var x__$2 = cljs.core.async.impl.timers.skip_list_node.call(null,k,v,(new Array(new_level)));
|
||||
var i = (0);
|
||||
while(true){
|
||||
if((i <= self__.level)){
|
||||
var links = (update[i]).forward;
|
||||
(x__$2.forward[i] = (links[i]));
|
||||
|
||||
return (links[i] = x__$2);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
cljs.core.async.impl.timers.SkipList.prototype.remove = (function (k){
|
||||
var self__ = this;
|
||||
var coll = this;
|
||||
var update = (new Array(cljs.core.async.impl.timers.MAX_LEVEL));
|
||||
var x = cljs.core.async.impl.timers.least_greater_node.call(null,self__.header,k,self__.level,update);
|
||||
var x__$1 = (((x.forward.length === (0)))?null:(x.forward[(0)]));
|
||||
if((((!((x__$1 == null)))) && ((x__$1.key === k)))){
|
||||
var i_23620 = (0);
|
||||
while(true){
|
||||
if((i_23620 <= self__.level)){
|
||||
var links_23621 = (update[i_23620]).forward;
|
||||
if((x__$1 === (((i_23620 < links_23621.length))?(links_23621[i_23620]):null))){
|
||||
(links_23621[i_23620] = (x__$1.forward[i_23620]));
|
||||
|
||||
var G__23622 = (i_23620 + (1));
|
||||
i_23620 = G__23622;
|
||||
continue;
|
||||
} else {
|
||||
var G__23623 = (i_23620 + (1));
|
||||
i_23620 = G__23623;
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
while(true){
|
||||
if(((((((0) < self__.level)) && ((self__.level < self__.header.forward.length)))) && (((self__.header.forward[self__.level]) == null)))){
|
||||
self__.level = (self__.level - (1));
|
||||
|
||||
continue;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
cljs.core.async.impl.timers.SkipList.prototype.ceilingEntry = (function (k){
|
||||
var self__ = this;
|
||||
var coll = this;
|
||||
var x = self__.header;
|
||||
var level__$1 = self__.level;
|
||||
while(true){
|
||||
if((!((level__$1 < (0))))){
|
||||
var nx = (function (){var x__$1 = x;
|
||||
while(true){
|
||||
var x_SINGLEQUOTE_ = (((level__$1 < x__$1.forward.length))?(x__$1.forward[level__$1]):null);
|
||||
if((x_SINGLEQUOTE_ == null)){
|
||||
return null;
|
||||
} else {
|
||||
if((x_SINGLEQUOTE_.key >= k)){
|
||||
return x_SINGLEQUOTE_;
|
||||
} else {
|
||||
var G__23624 = x_SINGLEQUOTE_;
|
||||
x__$1 = G__23624;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
})();
|
||||
if((!((nx == null)))){
|
||||
var G__23625 = nx;
|
||||
var G__23626 = (level__$1 - (1));
|
||||
x = G__23625;
|
||||
level__$1 = G__23626;
|
||||
continue;
|
||||
} else {
|
||||
var G__23627 = x;
|
||||
var G__23628 = (level__$1 - (1));
|
||||
x = G__23627;
|
||||
level__$1 = G__23628;
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
if((x === self__.header)){
|
||||
return null;
|
||||
} else {
|
||||
return x;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
cljs.core.async.impl.timers.SkipList.prototype.floorEntry = (function (k){
|
||||
var self__ = this;
|
||||
var coll = this;
|
||||
var x = self__.header;
|
||||
var level__$1 = self__.level;
|
||||
while(true){
|
||||
if((!((level__$1 < (0))))){
|
||||
var nx = (function (){var x__$1 = x;
|
||||
while(true){
|
||||
var x_SINGLEQUOTE_ = (((level__$1 < x__$1.forward.length))?(x__$1.forward[level__$1]):null);
|
||||
if((!((x_SINGLEQUOTE_ == null)))){
|
||||
if((x_SINGLEQUOTE_.key > k)){
|
||||
return x__$1;
|
||||
} else {
|
||||
var G__23629 = x_SINGLEQUOTE_;
|
||||
x__$1 = G__23629;
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
if((level__$1 === (0))){
|
||||
return x__$1;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
})();
|
||||
if(cljs.core.truth_(nx)){
|
||||
var G__23630 = nx;
|
||||
var G__23631 = (level__$1 - (1));
|
||||
x = G__23630;
|
||||
level__$1 = G__23631;
|
||||
continue;
|
||||
} else {
|
||||
var G__23632 = x;
|
||||
var G__23633 = (level__$1 - (1));
|
||||
x = G__23632;
|
||||
level__$1 = G__23633;
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
if((x === self__.header)){
|
||||
return null;
|
||||
} else {
|
||||
return x;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
cljs.core.async.impl.timers.SkipList.prototype.cljs$core$ISeqable$_seq$arity$1 = (function (coll){
|
||||
var self__ = this;
|
||||
var coll__$1 = this;
|
||||
var iter = ((function (coll__$1){
|
||||
return (function cljs$core$async$impl$timers$iter(node){
|
||||
return (new cljs.core.LazySeq(null,((function (coll__$1){
|
||||
return (function (){
|
||||
if((node == null)){
|
||||
return null;
|
||||
} else {
|
||||
return cljs.core.cons.call(null,new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [node.key,node.val], null),cljs$core$async$impl$timers$iter.call(null,(node.forward[(0)])));
|
||||
}
|
||||
});})(coll__$1))
|
||||
,null,null));
|
||||
});})(coll__$1))
|
||||
;
|
||||
return iter.call(null,(self__.header.forward[(0)]));
|
||||
});
|
||||
|
||||
cljs.core.async.impl.timers.SkipList.prototype.cljs$core$IPrintWithWriter$_pr_writer$arity$3 = (function (coll,writer,opts){
|
||||
var self__ = this;
|
||||
var coll__$1 = this;
|
||||
var pr_pair = ((function (coll__$1){
|
||||
return (function (keyval){
|
||||
return cljs.core.pr_sequential_writer.call(null,writer,cljs.core.pr_writer,""," ","",opts,keyval);
|
||||
});})(coll__$1))
|
||||
;
|
||||
return cljs.core.pr_sequential_writer.call(null,writer,pr_pair,"{",", ","}",opts,coll__$1);
|
||||
});
|
||||
|
||||
cljs.core.async.impl.timers.SkipList.getBasis = (function (){
|
||||
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Symbol(null,"header","header",1759972661,null),cljs.core.with_meta(new cljs.core.Symbol(null,"level","level",-1363938217,null),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"mutable","mutable",875778266),true], null))], null);
|
||||
});
|
||||
|
||||
cljs.core.async.impl.timers.SkipList.cljs$lang$type = true;
|
||||
|
||||
cljs.core.async.impl.timers.SkipList.cljs$lang$ctorStr = "cljs.core.async.impl.timers/SkipList";
|
||||
|
||||
cljs.core.async.impl.timers.SkipList.cljs$lang$ctorPrWriter = (function (this__4374__auto__,writer__4375__auto__,opt__4376__auto__){
|
||||
return cljs.core._write.call(null,writer__4375__auto__,"cljs.core.async.impl.timers/SkipList");
|
||||
});
|
||||
|
||||
/**
|
||||
* Positional factory function for cljs.core.async.impl.timers/SkipList.
|
||||
*/
|
||||
cljs.core.async.impl.timers.__GT_SkipList = (function cljs$core$async$impl$timers$__GT_SkipList(header,level){
|
||||
return (new cljs.core.async.impl.timers.SkipList(header,level));
|
||||
});
|
||||
|
||||
cljs.core.async.impl.timers.skip_list = (function cljs$core$async$impl$timers$skip_list(){
|
||||
return (new cljs.core.async.impl.timers.SkipList(cljs.core.async.impl.timers.skip_list_node.call(null,(0)),(0)));
|
||||
});
|
||||
cljs.core.async.impl.timers.timeouts_map = cljs.core.async.impl.timers.skip_list.call(null);
|
||||
cljs.core.async.impl.timers.TIMEOUT_RESOLUTION_MS = (10);
|
||||
/**
|
||||
* returns a channel that will close after msecs
|
||||
*/
|
||||
cljs.core.async.impl.timers.timeout = (function cljs$core$async$impl$timers$timeout(msecs){
|
||||
var timeout = ((new Date()).valueOf() + msecs);
|
||||
var me = cljs.core.async.impl.timers.timeouts_map.ceilingEntry(timeout);
|
||||
var or__4131__auto__ = (cljs.core.truth_((function (){var and__4120__auto__ = me;
|
||||
if(cljs.core.truth_(and__4120__auto__)){
|
||||
return (me.key < (timeout + cljs.core.async.impl.timers.TIMEOUT_RESOLUTION_MS));
|
||||
} else {
|
||||
return and__4120__auto__;
|
||||
}
|
||||
})())?me.val:null);
|
||||
if(cljs.core.truth_(or__4131__auto__)){
|
||||
return or__4131__auto__;
|
||||
} else {
|
||||
var timeout_channel = cljs.core.async.impl.channels.chan.call(null,null);
|
||||
cljs.core.async.impl.timers.timeouts_map.put(timeout,timeout_channel);
|
||||
|
||||
cljs.core.async.impl.dispatch.queue_delay.call(null,((function (timeout_channel,or__4131__auto__,timeout,me){
|
||||
return (function (){
|
||||
cljs.core.async.impl.timers.timeouts_map.remove(timeout);
|
||||
|
||||
return cljs.core.async.impl.protocols.close_BANG_.call(null,timeout_channel);
|
||||
});})(timeout_channel,or__4131__auto__,timeout,me))
|
||||
,msecs);
|
||||
|
||||
return timeout_channel;
|
||||
}
|
||||
});
|
||||
|
||||
//# sourceMappingURL=timers.js.map
|
||||
File diff suppressed because one or more lines are too long
214
resources/public/target/cljsbuild-compiler-1/cljs/reader.cljs
Normal file
214
resources/public/target/cljsbuild-compiler-1/cljs/reader.cljs
Normal file
|
|
@ -0,0 +1,214 @@
|
|||
; Copyright (c) Rich Hickey. All rights reserved.
|
||||
; The use and distribution terms for this software are covered by the
|
||||
; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
|
||||
; which can be found in the file epl-v10.html at the root of this distribution.
|
||||
; By using this software in any fashion, you are agreeing to be bound by
|
||||
; the terms of this license.
|
||||
; You must not remove this notice, or any other, from this software.
|
||||
|
||||
(ns cljs.reader
|
||||
(:require-macros [cljs.reader :refer [add-data-readers]])
|
||||
(:require [goog.object :as gobject]
|
||||
[cljs.tools.reader :as treader]
|
||||
[cljs.tools.reader.edn :as edn])
|
||||
(:import [goog.string StringBuffer]))
|
||||
|
||||
(defn ^:private zero-fill-right-and-truncate [s width]
|
||||
(cond
|
||||
(= width (count s)) s
|
||||
(< width (count s)) (subs s 0 width)
|
||||
:else
|
||||
(loop [b (StringBuffer. s)]
|
||||
(if (< (.getLength b) width)
|
||||
(recur (.append b "0"))
|
||||
(.toString b)))))
|
||||
|
||||
(defn ^:private divisible?
|
||||
[num div]
|
||||
(zero? (mod num div)))
|
||||
|
||||
(defn ^:private indivisible?
|
||||
[num div]
|
||||
(not (divisible? num div)))
|
||||
|
||||
(defn ^:private leap-year?
|
||||
[year]
|
||||
(and (divisible? year 4)
|
||||
(or (indivisible? year 100)
|
||||
(divisible? year 400))))
|
||||
|
||||
(def ^:private days-in-month
|
||||
(let [dim-norm [nil 31 28 31 30 31 30 31 31 30 31 30 31]
|
||||
dim-leap [nil 31 29 31 30 31 30 31 31 30 31 30 31]]
|
||||
(fn [month leap-year?]
|
||||
(get (if leap-year? dim-leap dim-norm) month))))
|
||||
|
||||
(def ^:private timestamp-regex #"(\d\d\d\d)(?:-(\d\d)(?:-(\d\d)(?:[T](\d\d)(?::(\d\d)(?::(\d\d)(?:[.](\d+))?)?)?)?)?)?(?:[Z]|([-+])(\d\d):(\d\d))?")
|
||||
|
||||
(defn ^:private parse-int [s]
|
||||
(let [n (js/parseInt s 10)]
|
||||
(if-not (js/isNaN n)
|
||||
n)))
|
||||
|
||||
(defn ^:private check [low n high msg]
|
||||
(when-not (<= low n high)
|
||||
(throw (js/Error. (str msg " Failed: " low "<=" n "<=" high))))
|
||||
n)
|
||||
|
||||
(defn parse-and-validate-timestamp [s]
|
||||
(let [[_ years months days hours minutes seconds fraction offset-sign offset-hours offset-minutes :as v]
|
||||
(re-matches timestamp-regex s)]
|
||||
(if-not v
|
||||
(throw (js/Error. (str "Unrecognized date/time syntax: " s)))
|
||||
(let [years (parse-int years)
|
||||
months (or (parse-int months) 1)
|
||||
days (or (parse-int days) 1)
|
||||
hours (or (parse-int hours) 0)
|
||||
minutes (or (parse-int minutes) 0)
|
||||
seconds (or (parse-int seconds) 0)
|
||||
fraction (or (parse-int (zero-fill-right-and-truncate fraction 3)) 0)
|
||||
offset-sign (if (= offset-sign "-") -1 1)
|
||||
offset-hours (or (parse-int offset-hours) 0)
|
||||
offset-minutes (or (parse-int offset-minutes) 0)
|
||||
offset (* offset-sign (+ (* offset-hours 60) offset-minutes))]
|
||||
[years
|
||||
(check 1 months 12 "timestamp month field must be in range 1..12")
|
||||
(check 1 days (days-in-month months (leap-year? years)) "timestamp day field must be in range 1..last day in month")
|
||||
(check 0 hours 23 "timestamp hour field must be in range 0..23")
|
||||
(check 0 minutes 59 "timestamp minute field must be in range 0..59")
|
||||
(check 0 seconds (if (= minutes 59) 60 59) "timestamp second field must be in range 0..60")
|
||||
(check 0 fraction 999 "timestamp millisecond field must be in range 0..999")
|
||||
offset]))))
|
||||
|
||||
(defn parse-timestamp
|
||||
[ts]
|
||||
(if-let [[years months days hours minutes seconds ms offset]
|
||||
(parse-and-validate-timestamp ts)]
|
||||
(js/Date.
|
||||
(- (.UTC js/Date years (dec months) days hours minutes seconds ms)
|
||||
(* offset 60 1000)))
|
||||
(throw (js/Error. (str "Unrecognized date/time syntax: " ts)))))
|
||||
|
||||
(defn ^:private read-date
|
||||
[s]
|
||||
(if (string? s)
|
||||
(parse-timestamp s)
|
||||
(throw (js/Error. "Instance literal expects a string for its timestamp."))))
|
||||
|
||||
(defn ^:private read-queue
|
||||
[elems]
|
||||
(if (vector? elems)
|
||||
(into cljs.core/PersistentQueue.EMPTY elems)
|
||||
(throw (js/Error. "Queue literal expects a vector for its elements."))))
|
||||
|
||||
(defn ^:private read-js
|
||||
[form]
|
||||
(cond
|
||||
(vector? form)
|
||||
(let [arr (array)]
|
||||
(doseq [x form]
|
||||
(.push arr x))
|
||||
arr)
|
||||
|
||||
(map? form)
|
||||
(let [obj (js-obj)]
|
||||
(doseq [[k v] form]
|
||||
(gobject/set obj (name k) v))
|
||||
obj)
|
||||
|
||||
:else
|
||||
(throw
|
||||
(js/Error.
|
||||
(str "JS literal expects a vector or map containing "
|
||||
"only string or unqualified keyword keys")))))
|
||||
|
||||
(defn ^:private read-uuid
|
||||
[uuid]
|
||||
(if (string? uuid)
|
||||
(cljs.core/uuid uuid)
|
||||
(throw (js/Error. "UUID literal expects a string as its representation."))))
|
||||
|
||||
(def ^:dynamic *default-data-reader-fn*
|
||||
(atom nil))
|
||||
|
||||
(def ^:dynamic *tag-table*
|
||||
(atom
|
||||
(add-data-readers
|
||||
{'inst read-date
|
||||
'uuid read-uuid
|
||||
'queue read-queue
|
||||
'js read-js})))
|
||||
|
||||
(defn read
|
||||
"Reads the first object from an cljs.tools.reader.reader-types/IPushbackReader.
|
||||
Returns the object read. If EOF, throws if eof-error? is true otherwise returns eof.
|
||||
If no reader is provided, *in* will be used.
|
||||
|
||||
Reads data in the edn format (subset of Clojure data):
|
||||
http://edn-format.org
|
||||
|
||||
cljs.tools.reader.edn/read doesn't depend on dynamic Vars, all configuration
|
||||
is done by passing an opt map.
|
||||
|
||||
opts is a map that can include the following keys:
|
||||
:eof - value to return on end-of-file. When not supplied, eof throws an exception.
|
||||
:readers - a map of tag symbols to data-reader functions to be considered before default-data-readers.
|
||||
When not supplied, only the default-data-readers will be used.
|
||||
:default - A function of two args, that will, if present and no reader is found for a tag,
|
||||
be called with the tag and the value."
|
||||
([reader]
|
||||
(edn/read
|
||||
{:readers @*tag-table*
|
||||
:default @*default-data-reader-fn*
|
||||
:eof nil}
|
||||
reader))
|
||||
([{:keys [eof] :as opts} reader]
|
||||
(edn/read
|
||||
(update (merge opts {:default @*default-data-reader-fn*})
|
||||
:readers (fn [m] (merge @*tag-table* m))) reader))
|
||||
([reader eof-error? eof opts]
|
||||
(edn/read reader eof-error? eof
|
||||
(update (merge opts {:default @*default-data-reader-fn*})
|
||||
:readers (fn [m] (merge @*tag-table* m))))))
|
||||
|
||||
(defn read-string
|
||||
"Reads one object from the string s.
|
||||
Returns nil when s is nil or empty.
|
||||
|
||||
Reads data in the edn format (subset of Clojure data):
|
||||
http://edn-format.org
|
||||
|
||||
opts is a map as per cljs.tools.reader.edn/read"
|
||||
([s]
|
||||
(edn/read-string
|
||||
{:readers @*tag-table*
|
||||
:default @*default-data-reader-fn*
|
||||
:eof nil} s))
|
||||
([opts s]
|
||||
(edn/read-string
|
||||
(update (merge {:default @*default-data-reader-fn*} opts)
|
||||
:readers (fn [m] (merge @*tag-table* m))) s)))
|
||||
|
||||
(defn register-tag-parser!
|
||||
[tag f]
|
||||
(let [old-parser (get @*tag-table* tag)]
|
||||
(swap! *tag-table* assoc tag f)
|
||||
old-parser))
|
||||
|
||||
(defn deregister-tag-parser!
|
||||
[tag]
|
||||
(let [old-parser (get @*tag-table* tag)]
|
||||
(swap! *tag-table* dissoc tag)
|
||||
old-parser))
|
||||
|
||||
(defn register-default-tag-parser!
|
||||
[f]
|
||||
(let [old-parser @*default-data-reader-fn*]
|
||||
(swap! *default-data-reader-fn* (fn [_] f))
|
||||
old-parser))
|
||||
|
||||
(defn deregister-default-tag-parser!
|
||||
[]
|
||||
(let [old-parser @*default-data-reader-fn*]
|
||||
(swap! *default-data-reader-fn* (fn [_] nil))
|
||||
old-parser))
|
||||
File diff suppressed because one or more lines are too long
445
resources/public/target/cljsbuild-compiler-1/cljs/reader.js
Normal file
445
resources/public/target/cljsbuild-compiler-1/cljs/reader.js
Normal file
|
|
@ -0,0 +1,445 @@
|
|||
// Compiled by ClojureScript 1.10.520 {}
|
||||
goog.provide('cljs.reader');
|
||||
goog.require('cljs.core');
|
||||
goog.require('goog.object');
|
||||
goog.require('cljs.tools.reader');
|
||||
goog.require('cljs.tools.reader.edn');
|
||||
goog.require('goog.string.StringBuffer');
|
||||
cljs.reader.zero_fill_right_and_truncate = (function cljs$reader$zero_fill_right_and_truncate(s,width){
|
||||
if(cljs.core._EQ_.call(null,width,cljs.core.count.call(null,s))){
|
||||
return s;
|
||||
} else {
|
||||
if((width < cljs.core.count.call(null,s))){
|
||||
return cljs.core.subs.call(null,s,(0),width);
|
||||
} else {
|
||||
var b = (new goog.string.StringBuffer(s));
|
||||
while(true){
|
||||
if((b.getLength() < width)){
|
||||
var G__21991 = b.append("0");
|
||||
b = G__21991;
|
||||
continue;
|
||||
} else {
|
||||
return b.toString();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
cljs.reader.divisible_QMARK_ = (function cljs$reader$divisible_QMARK_(num,div){
|
||||
return (cljs.core.mod.call(null,num,div) === (0));
|
||||
});
|
||||
cljs.reader.indivisible_QMARK_ = (function cljs$reader$indivisible_QMARK_(num,div){
|
||||
return (!(cljs.reader.divisible_QMARK_.call(null,num,div)));
|
||||
});
|
||||
cljs.reader.leap_year_QMARK_ = (function cljs$reader$leap_year_QMARK_(year){
|
||||
return ((cljs.reader.divisible_QMARK_.call(null,year,(4))) && (((cljs.reader.indivisible_QMARK_.call(null,year,(100))) || (cljs.reader.divisible_QMARK_.call(null,year,(400))))));
|
||||
});
|
||||
cljs.reader.days_in_month = (function (){var dim_norm = new cljs.core.PersistentVector(null, 13, 5, cljs.core.PersistentVector.EMPTY_NODE, [null,(31),(28),(31),(30),(31),(30),(31),(31),(30),(31),(30),(31)], null);
|
||||
var dim_leap = new cljs.core.PersistentVector(null, 13, 5, cljs.core.PersistentVector.EMPTY_NODE, [null,(31),(29),(31),(30),(31),(30),(31),(31),(30),(31),(30),(31)], null);
|
||||
return ((function (dim_norm,dim_leap){
|
||||
return (function (month,leap_year_QMARK_){
|
||||
return cljs.core.get.call(null,(cljs.core.truth_(leap_year_QMARK_)?dim_leap:dim_norm),month);
|
||||
});
|
||||
;})(dim_norm,dim_leap))
|
||||
})();
|
||||
cljs.reader.timestamp_regex = /(\d\d\d\d)(?:-(\d\d)(?:-(\d\d)(?:[T](\d\d)(?::(\d\d)(?::(\d\d)(?:[.](\d+))?)?)?)?)?)?(?:[Z]|([-+])(\d\d):(\d\d))?/;
|
||||
cljs.reader.parse_int = (function cljs$reader$parse_int(s){
|
||||
var n = parseInt(s,(10));
|
||||
if(cljs.core.not.call(null,isNaN(n))){
|
||||
return n;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
cljs.reader.check = (function cljs$reader$check(low,n,high,msg){
|
||||
if((((low <= n)) && ((n <= high)))){
|
||||
} else {
|
||||
throw (new Error([cljs.core.str.cljs$core$IFn$_invoke$arity$1(msg)," Failed: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(low),"<=",cljs.core.str.cljs$core$IFn$_invoke$arity$1(n),"<=",cljs.core.str.cljs$core$IFn$_invoke$arity$1(high)].join('')));
|
||||
}
|
||||
|
||||
return n;
|
||||
});
|
||||
cljs.reader.parse_and_validate_timestamp = (function cljs$reader$parse_and_validate_timestamp(s){
|
||||
var vec__21992 = cljs.core.re_matches.call(null,cljs.reader.timestamp_regex,s);
|
||||
var _ = cljs.core.nth.call(null,vec__21992,(0),null);
|
||||
var years = cljs.core.nth.call(null,vec__21992,(1),null);
|
||||
var months = cljs.core.nth.call(null,vec__21992,(2),null);
|
||||
var days = cljs.core.nth.call(null,vec__21992,(3),null);
|
||||
var hours = cljs.core.nth.call(null,vec__21992,(4),null);
|
||||
var minutes = cljs.core.nth.call(null,vec__21992,(5),null);
|
||||
var seconds = cljs.core.nth.call(null,vec__21992,(6),null);
|
||||
var fraction = cljs.core.nth.call(null,vec__21992,(7),null);
|
||||
var offset_sign = cljs.core.nth.call(null,vec__21992,(8),null);
|
||||
var offset_hours = cljs.core.nth.call(null,vec__21992,(9),null);
|
||||
var offset_minutes = cljs.core.nth.call(null,vec__21992,(10),null);
|
||||
var v = vec__21992;
|
||||
if(cljs.core.not.call(null,v)){
|
||||
throw (new Error(["Unrecognized date/time syntax: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(s)].join('')));
|
||||
} else {
|
||||
var years__$1 = cljs.reader.parse_int.call(null,years);
|
||||
var months__$1 = (function (){var or__4131__auto__ = cljs.reader.parse_int.call(null,months);
|
||||
if(cljs.core.truth_(or__4131__auto__)){
|
||||
return or__4131__auto__;
|
||||
} else {
|
||||
return (1);
|
||||
}
|
||||
})();
|
||||
var days__$1 = (function (){var or__4131__auto__ = cljs.reader.parse_int.call(null,days);
|
||||
if(cljs.core.truth_(or__4131__auto__)){
|
||||
return or__4131__auto__;
|
||||
} else {
|
||||
return (1);
|
||||
}
|
||||
})();
|
||||
var hours__$1 = (function (){var or__4131__auto__ = cljs.reader.parse_int.call(null,hours);
|
||||
if(cljs.core.truth_(or__4131__auto__)){
|
||||
return or__4131__auto__;
|
||||
} else {
|
||||
return (0);
|
||||
}
|
||||
})();
|
||||
var minutes__$1 = (function (){var or__4131__auto__ = cljs.reader.parse_int.call(null,minutes);
|
||||
if(cljs.core.truth_(or__4131__auto__)){
|
||||
return or__4131__auto__;
|
||||
} else {
|
||||
return (0);
|
||||
}
|
||||
})();
|
||||
var seconds__$1 = (function (){var or__4131__auto__ = cljs.reader.parse_int.call(null,seconds);
|
||||
if(cljs.core.truth_(or__4131__auto__)){
|
||||
return or__4131__auto__;
|
||||
} else {
|
||||
return (0);
|
||||
}
|
||||
})();
|
||||
var fraction__$1 = (function (){var or__4131__auto__ = cljs.reader.parse_int.call(null,cljs.reader.zero_fill_right_and_truncate.call(null,fraction,(3)));
|
||||
if(cljs.core.truth_(or__4131__auto__)){
|
||||
return or__4131__auto__;
|
||||
} else {
|
||||
return (0);
|
||||
}
|
||||
})();
|
||||
var offset_sign__$1 = ((cljs.core._EQ_.call(null,offset_sign,"-"))?(-1):(1));
|
||||
var offset_hours__$1 = (function (){var or__4131__auto__ = cljs.reader.parse_int.call(null,offset_hours);
|
||||
if(cljs.core.truth_(or__4131__auto__)){
|
||||
return or__4131__auto__;
|
||||
} else {
|
||||
return (0);
|
||||
}
|
||||
})();
|
||||
var offset_minutes__$1 = (function (){var or__4131__auto__ = cljs.reader.parse_int.call(null,offset_minutes);
|
||||
if(cljs.core.truth_(or__4131__auto__)){
|
||||
return or__4131__auto__;
|
||||
} else {
|
||||
return (0);
|
||||
}
|
||||
})();
|
||||
var offset = (offset_sign__$1 * ((offset_hours__$1 * (60)) + offset_minutes__$1));
|
||||
return new cljs.core.PersistentVector(null, 8, 5, cljs.core.PersistentVector.EMPTY_NODE, [years__$1,cljs.reader.check.call(null,(1),months__$1,(12),"timestamp month field must be in range 1..12"),cljs.reader.check.call(null,(1),days__$1,cljs.reader.days_in_month.call(null,months__$1,cljs.reader.leap_year_QMARK_.call(null,years__$1)),"timestamp day field must be in range 1..last day in month"),cljs.reader.check.call(null,(0),hours__$1,(23),"timestamp hour field must be in range 0..23"),cljs.reader.check.call(null,(0),minutes__$1,(59),"timestamp minute field must be in range 0..59"),cljs.reader.check.call(null,(0),seconds__$1,((cljs.core._EQ_.call(null,minutes__$1,(59)))?(60):(59)),"timestamp second field must be in range 0..60"),cljs.reader.check.call(null,(0),fraction__$1,(999),"timestamp millisecond field must be in range 0..999"),offset], null);
|
||||
}
|
||||
});
|
||||
cljs.reader.parse_timestamp = (function cljs$reader$parse_timestamp(ts){
|
||||
var temp__5718__auto__ = cljs.reader.parse_and_validate_timestamp.call(null,ts);
|
||||
if(cljs.core.truth_(temp__5718__auto__)){
|
||||
var vec__21995 = temp__5718__auto__;
|
||||
var years = cljs.core.nth.call(null,vec__21995,(0),null);
|
||||
var months = cljs.core.nth.call(null,vec__21995,(1),null);
|
||||
var days = cljs.core.nth.call(null,vec__21995,(2),null);
|
||||
var hours = cljs.core.nth.call(null,vec__21995,(3),null);
|
||||
var minutes = cljs.core.nth.call(null,vec__21995,(4),null);
|
||||
var seconds = cljs.core.nth.call(null,vec__21995,(5),null);
|
||||
var ms = cljs.core.nth.call(null,vec__21995,(6),null);
|
||||
var offset = cljs.core.nth.call(null,vec__21995,(7),null);
|
||||
return (new Date((Date.UTC(years,(months - (1)),days,hours,minutes,seconds,ms) - ((offset * (60)) * (1000)))));
|
||||
} else {
|
||||
throw (new Error(["Unrecognized date/time syntax: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(ts)].join('')));
|
||||
}
|
||||
});
|
||||
cljs.reader.read_date = (function cljs$reader$read_date(s){
|
||||
if(typeof s === 'string'){
|
||||
return cljs.reader.parse_timestamp.call(null,s);
|
||||
} else {
|
||||
throw (new Error("Instance literal expects a string for its timestamp."));
|
||||
}
|
||||
});
|
||||
cljs.reader.read_queue = (function cljs$reader$read_queue(elems){
|
||||
if(cljs.core.vector_QMARK_.call(null,elems)){
|
||||
return cljs.core.into.call(null,cljs.core.PersistentQueue.EMPTY,elems);
|
||||
} else {
|
||||
throw (new Error("Queue literal expects a vector for its elements."));
|
||||
}
|
||||
});
|
||||
cljs.reader.read_js = (function cljs$reader$read_js(form){
|
||||
if(cljs.core.vector_QMARK_.call(null,form)){
|
||||
var arr = [];
|
||||
var seq__21998_22020 = cljs.core.seq.call(null,form);
|
||||
var chunk__21999_22021 = null;
|
||||
var count__22000_22022 = (0);
|
||||
var i__22001_22023 = (0);
|
||||
while(true){
|
||||
if((i__22001_22023 < count__22000_22022)){
|
||||
var x_22024 = cljs.core._nth.call(null,chunk__21999_22021,i__22001_22023);
|
||||
arr.push(x_22024);
|
||||
|
||||
|
||||
var G__22025 = seq__21998_22020;
|
||||
var G__22026 = chunk__21999_22021;
|
||||
var G__22027 = count__22000_22022;
|
||||
var G__22028 = (i__22001_22023 + (1));
|
||||
seq__21998_22020 = G__22025;
|
||||
chunk__21999_22021 = G__22026;
|
||||
count__22000_22022 = G__22027;
|
||||
i__22001_22023 = G__22028;
|
||||
continue;
|
||||
} else {
|
||||
var temp__5720__auto___22029 = cljs.core.seq.call(null,seq__21998_22020);
|
||||
if(temp__5720__auto___22029){
|
||||
var seq__21998_22030__$1 = temp__5720__auto___22029;
|
||||
if(cljs.core.chunked_seq_QMARK_.call(null,seq__21998_22030__$1)){
|
||||
var c__4550__auto___22031 = cljs.core.chunk_first.call(null,seq__21998_22030__$1);
|
||||
var G__22032 = cljs.core.chunk_rest.call(null,seq__21998_22030__$1);
|
||||
var G__22033 = c__4550__auto___22031;
|
||||
var G__22034 = cljs.core.count.call(null,c__4550__auto___22031);
|
||||
var G__22035 = (0);
|
||||
seq__21998_22020 = G__22032;
|
||||
chunk__21999_22021 = G__22033;
|
||||
count__22000_22022 = G__22034;
|
||||
i__22001_22023 = G__22035;
|
||||
continue;
|
||||
} else {
|
||||
var x_22036 = cljs.core.first.call(null,seq__21998_22030__$1);
|
||||
arr.push(x_22036);
|
||||
|
||||
|
||||
var G__22037 = cljs.core.next.call(null,seq__21998_22030__$1);
|
||||
var G__22038 = null;
|
||||
var G__22039 = (0);
|
||||
var G__22040 = (0);
|
||||
seq__21998_22020 = G__22037;
|
||||
chunk__21999_22021 = G__22038;
|
||||
count__22000_22022 = G__22039;
|
||||
i__22001_22023 = G__22040;
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return arr;
|
||||
} else {
|
||||
if(cljs.core.map_QMARK_.call(null,form)){
|
||||
var obj = ({});
|
||||
var seq__22004_22041 = cljs.core.seq.call(null,form);
|
||||
var chunk__22005_22042 = null;
|
||||
var count__22006_22043 = (0);
|
||||
var i__22007_22044 = (0);
|
||||
while(true){
|
||||
if((i__22007_22044 < count__22006_22043)){
|
||||
var vec__22014_22045 = cljs.core._nth.call(null,chunk__22005_22042,i__22007_22044);
|
||||
var k_22046 = cljs.core.nth.call(null,vec__22014_22045,(0),null);
|
||||
var v_22047 = cljs.core.nth.call(null,vec__22014_22045,(1),null);
|
||||
goog.object.set(obj,cljs.core.name.call(null,k_22046),v_22047);
|
||||
|
||||
|
||||
var G__22048 = seq__22004_22041;
|
||||
var G__22049 = chunk__22005_22042;
|
||||
var G__22050 = count__22006_22043;
|
||||
var G__22051 = (i__22007_22044 + (1));
|
||||
seq__22004_22041 = G__22048;
|
||||
chunk__22005_22042 = G__22049;
|
||||
count__22006_22043 = G__22050;
|
||||
i__22007_22044 = G__22051;
|
||||
continue;
|
||||
} else {
|
||||
var temp__5720__auto___22052 = cljs.core.seq.call(null,seq__22004_22041);
|
||||
if(temp__5720__auto___22052){
|
||||
var seq__22004_22053__$1 = temp__5720__auto___22052;
|
||||
if(cljs.core.chunked_seq_QMARK_.call(null,seq__22004_22053__$1)){
|
||||
var c__4550__auto___22054 = cljs.core.chunk_first.call(null,seq__22004_22053__$1);
|
||||
var G__22055 = cljs.core.chunk_rest.call(null,seq__22004_22053__$1);
|
||||
var G__22056 = c__4550__auto___22054;
|
||||
var G__22057 = cljs.core.count.call(null,c__4550__auto___22054);
|
||||
var G__22058 = (0);
|
||||
seq__22004_22041 = G__22055;
|
||||
chunk__22005_22042 = G__22056;
|
||||
count__22006_22043 = G__22057;
|
||||
i__22007_22044 = G__22058;
|
||||
continue;
|
||||
} else {
|
||||
var vec__22017_22059 = cljs.core.first.call(null,seq__22004_22053__$1);
|
||||
var k_22060 = cljs.core.nth.call(null,vec__22017_22059,(0),null);
|
||||
var v_22061 = cljs.core.nth.call(null,vec__22017_22059,(1),null);
|
||||
goog.object.set(obj,cljs.core.name.call(null,k_22060),v_22061);
|
||||
|
||||
|
||||
var G__22062 = cljs.core.next.call(null,seq__22004_22053__$1);
|
||||
var G__22063 = null;
|
||||
var G__22064 = (0);
|
||||
var G__22065 = (0);
|
||||
seq__22004_22041 = G__22062;
|
||||
chunk__22005_22042 = G__22063;
|
||||
count__22006_22043 = G__22064;
|
||||
i__22007_22044 = G__22065;
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return obj;
|
||||
} else {
|
||||
throw (new Error(["JS literal expects a vector or map containing ","only string or unqualified keyword keys"].join('')));
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
cljs.reader.read_uuid = (function cljs$reader$read_uuid(uuid){
|
||||
if(typeof uuid === 'string'){
|
||||
return cljs.core.uuid.call(null,uuid);
|
||||
} else {
|
||||
throw (new Error("UUID literal expects a string as its representation."));
|
||||
}
|
||||
});
|
||||
cljs.reader._STAR_default_data_reader_fn_STAR_ = cljs.core.atom.call(null,null);
|
||||
cljs.reader._STAR_tag_table_STAR_ = cljs.core.atom.call(null,cljs.core.merge.call(null,new cljs.core.PersistentArrayMap(null, 4, [new cljs.core.Symbol(null,"inst","inst",-2008473268,null),cljs.reader.read_date,new cljs.core.Symbol(null,"uuid","uuid",-504564192,null),cljs.reader.read_uuid,new cljs.core.Symbol(null,"queue","queue",-1198599890,null),cljs.reader.read_queue,new cljs.core.Symbol(null,"js","js",-886355190,null),cljs.reader.read_js], null),cljs.core.PersistentArrayMap.EMPTY));
|
||||
/**
|
||||
* Reads the first object from an cljs.tools.reader.reader-types/IPushbackReader.
|
||||
* Returns the object read. If EOF, throws if eof-error? is true otherwise returns eof.
|
||||
* If no reader is provided, *in* will be used.
|
||||
*
|
||||
* Reads data in the edn format (subset of Clojure data):
|
||||
* http://edn-format.org
|
||||
*
|
||||
* cljs.tools.reader.edn/read doesn't depend on dynamic Vars, all configuration
|
||||
* is done by passing an opt map.
|
||||
*
|
||||
* opts is a map that can include the following keys:
|
||||
* :eof - value to return on end-of-file. When not supplied, eof throws an exception.
|
||||
* :readers - a map of tag symbols to data-reader functions to be considered before default-data-readers.
|
||||
* When not supplied, only the default-data-readers will be used.
|
||||
* :default - A function of two args, that will, if present and no reader is found for a tag,
|
||||
* be called with the tag and the value.
|
||||
*/
|
||||
cljs.reader.read = (function cljs$reader$read(var_args){
|
||||
var G__22067 = arguments.length;
|
||||
switch (G__22067) {
|
||||
case 1:
|
||||
return cljs.reader.read.cljs$core$IFn$_invoke$arity$1((arguments[(0)]));
|
||||
|
||||
break;
|
||||
case 2:
|
||||
return cljs.reader.read.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)]));
|
||||
|
||||
break;
|
||||
case 4:
|
||||
return cljs.reader.read.cljs$core$IFn$_invoke$arity$4((arguments[(0)]),(arguments[(1)]),(arguments[(2)]),(arguments[(3)]));
|
||||
|
||||
break;
|
||||
default:
|
||||
throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
cljs.reader.read.cljs$core$IFn$_invoke$arity$1 = (function (reader){
|
||||
return cljs.tools.reader.edn.read.call(null,new cljs.core.PersistentArrayMap(null, 3, [new cljs.core.Keyword(null,"readers","readers",-2118263030),cljs.core.deref.call(null,cljs.reader._STAR_tag_table_STAR_),new cljs.core.Keyword(null,"default","default",-1987822328),cljs.core.deref.call(null,cljs.reader._STAR_default_data_reader_fn_STAR_),new cljs.core.Keyword(null,"eof","eof",-489063237),null], null),reader);
|
||||
});
|
||||
|
||||
cljs.reader.read.cljs$core$IFn$_invoke$arity$2 = (function (p__22068,reader){
|
||||
var map__22069 = p__22068;
|
||||
var map__22069__$1 = (((((!((map__22069 == null))))?(((((map__22069.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__22069.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__22069):map__22069);
|
||||
var opts = map__22069__$1;
|
||||
var eof = cljs.core.get.call(null,map__22069__$1,new cljs.core.Keyword(null,"eof","eof",-489063237));
|
||||
return cljs.tools.reader.edn.read.call(null,cljs.core.update.call(null,cljs.core.merge.call(null,opts,new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"default","default",-1987822328),cljs.core.deref.call(null,cljs.reader._STAR_default_data_reader_fn_STAR_)], null)),new cljs.core.Keyword(null,"readers","readers",-2118263030),((function (map__22069,map__22069__$1,opts,eof){
|
||||
return (function (m){
|
||||
return cljs.core.merge.call(null,cljs.core.deref.call(null,cljs.reader._STAR_tag_table_STAR_),m);
|
||||
});})(map__22069,map__22069__$1,opts,eof))
|
||||
),reader);
|
||||
});
|
||||
|
||||
cljs.reader.read.cljs$core$IFn$_invoke$arity$4 = (function (reader,eof_error_QMARK_,eof,opts){
|
||||
return cljs.tools.reader.edn.read.call(null,reader,eof_error_QMARK_,eof,cljs.core.update.call(null,cljs.core.merge.call(null,opts,new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"default","default",-1987822328),cljs.core.deref.call(null,cljs.reader._STAR_default_data_reader_fn_STAR_)], null)),new cljs.core.Keyword(null,"readers","readers",-2118263030),(function (m){
|
||||
return cljs.core.merge.call(null,cljs.core.deref.call(null,cljs.reader._STAR_tag_table_STAR_),m);
|
||||
})));
|
||||
});
|
||||
|
||||
cljs.reader.read.cljs$lang$maxFixedArity = 4;
|
||||
|
||||
/**
|
||||
* Reads one object from the string s.
|
||||
* Returns nil when s is nil or empty.
|
||||
*
|
||||
* Reads data in the edn format (subset of Clojure data):
|
||||
* http://edn-format.org
|
||||
*
|
||||
* opts is a map as per cljs.tools.reader.edn/read
|
||||
*/
|
||||
cljs.reader.read_string = (function cljs$reader$read_string(var_args){
|
||||
var G__22073 = arguments.length;
|
||||
switch (G__22073) {
|
||||
case 1:
|
||||
return cljs.reader.read_string.cljs$core$IFn$_invoke$arity$1((arguments[(0)]));
|
||||
|
||||
break;
|
||||
case 2:
|
||||
return cljs.reader.read_string.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)]));
|
||||
|
||||
break;
|
||||
default:
|
||||
throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
cljs.reader.read_string.cljs$core$IFn$_invoke$arity$1 = (function (s){
|
||||
return cljs.tools.reader.edn.read_string.call(null,new cljs.core.PersistentArrayMap(null, 3, [new cljs.core.Keyword(null,"readers","readers",-2118263030),cljs.core.deref.call(null,cljs.reader._STAR_tag_table_STAR_),new cljs.core.Keyword(null,"default","default",-1987822328),cljs.core.deref.call(null,cljs.reader._STAR_default_data_reader_fn_STAR_),new cljs.core.Keyword(null,"eof","eof",-489063237),null], null),s);
|
||||
});
|
||||
|
||||
cljs.reader.read_string.cljs$core$IFn$_invoke$arity$2 = (function (opts,s){
|
||||
return cljs.tools.reader.edn.read_string.call(null,cljs.core.update.call(null,cljs.core.merge.call(null,new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"default","default",-1987822328),cljs.core.deref.call(null,cljs.reader._STAR_default_data_reader_fn_STAR_)], null),opts),new cljs.core.Keyword(null,"readers","readers",-2118263030),(function (m){
|
||||
return cljs.core.merge.call(null,cljs.core.deref.call(null,cljs.reader._STAR_tag_table_STAR_),m);
|
||||
})),s);
|
||||
});
|
||||
|
||||
cljs.reader.read_string.cljs$lang$maxFixedArity = 2;
|
||||
|
||||
cljs.reader.register_tag_parser_BANG_ = (function cljs$reader$register_tag_parser_BANG_(tag,f){
|
||||
var old_parser = cljs.core.get.call(null,cljs.core.deref.call(null,cljs.reader._STAR_tag_table_STAR_),tag);
|
||||
cljs.core.swap_BANG_.call(null,cljs.reader._STAR_tag_table_STAR_,cljs.core.assoc,tag,f);
|
||||
|
||||
return old_parser;
|
||||
});
|
||||
cljs.reader.deregister_tag_parser_BANG_ = (function cljs$reader$deregister_tag_parser_BANG_(tag){
|
||||
var old_parser = cljs.core.get.call(null,cljs.core.deref.call(null,cljs.reader._STAR_tag_table_STAR_),tag);
|
||||
cljs.core.swap_BANG_.call(null,cljs.reader._STAR_tag_table_STAR_,cljs.core.dissoc,tag);
|
||||
|
||||
return old_parser;
|
||||
});
|
||||
cljs.reader.register_default_tag_parser_BANG_ = (function cljs$reader$register_default_tag_parser_BANG_(f){
|
||||
var old_parser = cljs.core.deref.call(null,cljs.reader._STAR_default_data_reader_fn_STAR_);
|
||||
cljs.core.swap_BANG_.call(null,cljs.reader._STAR_default_data_reader_fn_STAR_,((function (old_parser){
|
||||
return (function (_){
|
||||
return f;
|
||||
});})(old_parser))
|
||||
);
|
||||
|
||||
return old_parser;
|
||||
});
|
||||
cljs.reader.deregister_default_tag_parser_BANG_ = (function cljs$reader$deregister_default_tag_parser_BANG_(){
|
||||
var old_parser = cljs.core.deref.call(null,cljs.reader._STAR_default_data_reader_fn_STAR_);
|
||||
cljs.core.swap_BANG_.call(null,cljs.reader._STAR_default_data_reader_fn_STAR_,((function (old_parser){
|
||||
return (function (_){
|
||||
return null;
|
||||
});})(old_parser))
|
||||
);
|
||||
|
||||
return old_parser;
|
||||
});
|
||||
|
||||
//# sourceMappingURL=reader.js.map
|
||||
File diff suppressed because one or more lines are too long
|
|
@ -0,0 +1,950 @@
|
|||
;; Copyright (c) Nicola Mometto, Rich Hickey & contributors.
|
||||
;; The use and distribution terms for this software are covered by the
|
||||
;; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
|
||||
;; which can be found in the file epl-v10.html at the root of this distribution.
|
||||
;; By using this software in any fashion, you are agreeing to be bound by
|
||||
;; the terms of this license.
|
||||
;; You must not remove this notice, or any other, from this software.
|
||||
|
||||
(ns ^{:doc "A clojure reader in clojure"
|
||||
:author "Bronsa"}
|
||||
cljs.tools.reader
|
||||
(:refer-clojure :exclude [read read-line read-string char read+string
|
||||
default-data-readers *default-data-reader-fn*
|
||||
*data-readers* *suppress-read*])
|
||||
(:require-macros [cljs.tools.reader.reader-types :refer [log-source]])
|
||||
(:require [cljs.tools.reader.reader-types :refer
|
||||
[read-char unread peek-char indexing-reader?
|
||||
get-line-number get-column-number get-file-name
|
||||
string-push-back-reader]]
|
||||
[cljs.tools.reader.impl.utils :refer
|
||||
[char ex-info? whitespace? numeric? desugar-meta next-id namespace-keys second'
|
||||
ReaderConditional reader-conditional reader-conditional? char-code]]
|
||||
[cljs.tools.reader.impl.commons :refer
|
||||
[number-literal? read-past match-number parse-symbol read-comment throwing-reader]]
|
||||
[cljs.tools.reader.impl.errors :as err]
|
||||
[goog.array :as garray]
|
||||
[goog.string :as gstring])
|
||||
(:import goog.string.StringBuffer))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; helpers
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(declare ^:private read*
|
||||
macros dispatch-macros
|
||||
^:dynamic *data-readers*
|
||||
^:dynamic *default-data-reader-fn*
|
||||
^:dynamic *suppress-read*
|
||||
default-data-readers)
|
||||
|
||||
(defn- ^boolean macro-terminating? [ch]
|
||||
(case ch
|
||||
(\" \; \@ \^ \` \~ \( \) \[ \] \{ \} \\) true
|
||||
false))
|
||||
|
||||
(def sb (StringBuffer.))
|
||||
|
||||
(defn- read-token
|
||||
"Read in a single logical token from the reader"
|
||||
[^not-native rdr kind initch]
|
||||
(if (nil? initch)
|
||||
(err/throw-eof-at-start rdr kind)
|
||||
(do
|
||||
(.clear sb)
|
||||
(loop [ch initch]
|
||||
(if (or (whitespace? ch)
|
||||
(macro-terminating? ch)
|
||||
(nil? ch))
|
||||
(do
|
||||
(when-not (nil? ch)
|
||||
(unread rdr ch))
|
||||
(.toString sb))
|
||||
(do
|
||||
(.append sb ch)
|
||||
(recur (read-char rdr))))))))
|
||||
|
||||
(declare read-tagged)
|
||||
|
||||
(defn- read-dispatch
|
||||
[^not-native rdr _ opts pending-forms]
|
||||
(if-let [ch (read-char rdr)]
|
||||
(if-let [dm (dispatch-macros ch)]
|
||||
(dm rdr ch opts pending-forms)
|
||||
(read-tagged (doto rdr (unread ch)) ch opts pending-forms)) ;; ctor reader is implemented as a tagged literal
|
||||
(err/throw-eof-at-dispatch rdr)))
|
||||
|
||||
(defn- read-unmatched-delimiter
|
||||
[rdr ch opts pending-forms]
|
||||
(err/throw-unmatch-delimiter rdr ch))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; readers
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(defn read-regex
|
||||
[^not-native rdr ch opts pending-forms]
|
||||
(let [sb (StringBuffer.)]
|
||||
(loop [ch (read-char rdr)]
|
||||
(if (identical? \" ch)
|
||||
(re-pattern (str sb))
|
||||
(if (nil? ch)
|
||||
(err/throw-eof-reading rdr :regex sb)
|
||||
(do
|
||||
(.append sb ch )
|
||||
(when (identical? \\ ch)
|
||||
(let [ch (read-char rdr)]
|
||||
(if (nil? ch)
|
||||
(err/throw-eof-reading rdr :regex sb))
|
||||
(.append sb ch)))
|
||||
(recur (read-char rdr))))))))
|
||||
|
||||
(defn- read-unicode-char
|
||||
([token offset length base]
|
||||
(let [l (+ offset length)]
|
||||
(when-not (== (count token) l)
|
||||
(err/throw-invalid-unicode-literal nil token))
|
||||
(loop [i offset uc 0]
|
||||
(if (== i l)
|
||||
(js/String.fromCharCode uc)
|
||||
(let [d (char-code (nth token i) base)]
|
||||
(if (== d -1)
|
||||
(err/throw-invalid-unicode-digit-in-token nil (nth token i) token)
|
||||
(recur (inc i) (+ d (* uc base)))))))))
|
||||
|
||||
([^not-native rdr initch base length exact?]
|
||||
(loop [i 1 uc (char-code initch base)]
|
||||
(if (== uc -1)
|
||||
(err/throw-invalid-unicode-digit rdr initch)
|
||||
(if-not (== i length)
|
||||
(let [ch (peek-char rdr)]
|
||||
(if (or (whitespace? ch)
|
||||
(macros ch)
|
||||
(nil? ch))
|
||||
(if exact?
|
||||
(err/throw-invalid-unicode-len rdr i length)
|
||||
(js/String.fromCharCode uc))
|
||||
(let [d (char-code ch base)]
|
||||
(read-char rdr)
|
||||
(if (== d -1)
|
||||
(err/throw-invalid-unicode-digit rdr ch)
|
||||
(recur (inc i) (+ d (* uc base)))))))
|
||||
(js/String.fromCharCode uc))))))
|
||||
|
||||
(def ^:private ^:const upper-limit (.charCodeAt \uD7ff 0))
|
||||
(def ^:private ^:const lower-limit (.charCodeAt \uE000 0))
|
||||
|
||||
(defn- valid-octal? [token base]
|
||||
(<= (js/parseInt token base) 0377))
|
||||
|
||||
(defn- read-char*
|
||||
"Read in a character literal"
|
||||
[^not-native rdr backslash opts pending-forms]
|
||||
(let [ch (read-char rdr)]
|
||||
(if-not (nil? ch)
|
||||
(let [token (if (or (macro-terminating? ch)
|
||||
(whitespace? ch))
|
||||
(str ch)
|
||||
(read-token rdr :character ch))
|
||||
token-len (. token -length)]
|
||||
(cond
|
||||
|
||||
(== 1 token-len) (.charAt token 0) ;;; no char type - so can't ensure/cache char
|
||||
|
||||
(= token "newline") \newline
|
||||
(= token "space") \space
|
||||
(= token "tab") \tab
|
||||
(= token "backspace") \backspace
|
||||
(= token "formfeed") \formfeed
|
||||
(= token "return") \return
|
||||
|
||||
(gstring/startsWith token "u")
|
||||
(let [c (read-unicode-char token 1 4 16)
|
||||
ic (.charCodeAt c 0)]
|
||||
(if (and (> ic upper-limit)
|
||||
(< ic lower-limit))
|
||||
(err/throw-invalid-character-literal rdr (.toString ic 16))
|
||||
c))
|
||||
|
||||
(gstring/startsWith token "o")
|
||||
(let [len (dec token-len)]
|
||||
(if (> len 3)
|
||||
(err/throw-invalid-octal-len rdr token)
|
||||
(let [offset 1
|
||||
base 8
|
||||
uc (read-unicode-char token offset len base)]
|
||||
(if-not (valid-octal? (subs token offset) base)
|
||||
(err/throw-bad-octal-number rdr)
|
||||
uc))))
|
||||
|
||||
:else (err/throw-unsupported-character rdr token)))
|
||||
(err/throw-eof-in-character rdr))))
|
||||
|
||||
(defn- starting-line-col-info [^not-native rdr]
|
||||
(when (indexing-reader? rdr)
|
||||
[(get-line-number rdr) (int (dec (get-column-number rdr)))]))
|
||||
|
||||
(defn- ending-line-col-info [^not-native rdr]
|
||||
(when (indexing-reader? rdr)
|
||||
[(get-line-number rdr) (get-column-number rdr)]))
|
||||
|
||||
(defonce ^:private READ_EOF (js/Object.))
|
||||
(defonce ^:private READ_FINISHED (js/Object.))
|
||||
|
||||
(def ^:dynamic *read-delim* false)
|
||||
|
||||
(defn- read-delimited-internal [kind delim rdr opts pending-forms]
|
||||
(let [[start-line start-column] (starting-line-col-info rdr)
|
||||
delim (char delim)]
|
||||
(loop [a (transient [])]
|
||||
(let [form (read* rdr false READ_EOF delim opts pending-forms)]
|
||||
(if (identical? form READ_FINISHED)
|
||||
(persistent! a)
|
||||
(if (identical? form READ_EOF)
|
||||
(err/throw-eof-delimited rdr kind start-line start-column (count a))
|
||||
(recur (conj! a form))))))))
|
||||
|
||||
(defn- read-delimited
|
||||
"Reads and returns a collection ended with delim"
|
||||
[kind delim rdr opts pending-forms]
|
||||
(binding [*read-delim* true]
|
||||
(read-delimited-internal kind delim rdr opts pending-forms)))
|
||||
|
||||
(defn- read-list
|
||||
"Read in a list, including its location if the reader is an indexing reader"
|
||||
[rdr _ opts pending-forms]
|
||||
(let [[start-line start-column] (starting-line-col-info rdr)
|
||||
the-list (read-delimited :list \) rdr opts pending-forms)
|
||||
[end-line end-column] (ending-line-col-info rdr)]
|
||||
(with-meta (if (empty? the-list)
|
||||
'()
|
||||
(apply list the-list))
|
||||
(when start-line
|
||||
(merge
|
||||
(when-let [file (get-file-name rdr)]
|
||||
{:file file})
|
||||
{:line start-line
|
||||
:column start-column
|
||||
:end-line end-line
|
||||
:end-column end-column})))))
|
||||
|
||||
(defn- read-vector
|
||||
"Read in a vector, including its location if the reader is an indexing reader"
|
||||
[rdr _ opts pending-forms]
|
||||
(let [[start-line start-column] (starting-line-col-info rdr)
|
||||
the-vector (read-delimited :vector \] rdr opts pending-forms)
|
||||
[end-line end-column] (ending-line-col-info rdr)]
|
||||
(with-meta the-vector
|
||||
(when start-line
|
||||
(merge
|
||||
(when-let [file (get-file-name rdr)]
|
||||
{:file file})
|
||||
{:line start-line
|
||||
:column start-column
|
||||
:end-line end-line
|
||||
:end-column end-column})))))
|
||||
|
||||
(defn- read-map
|
||||
"Read in a map, including its location if the reader is an indexing reader"
|
||||
[rdr _ opts pending-forms]
|
||||
(let [[start-line start-column] (starting-line-col-info rdr)
|
||||
the-map (read-delimited :map \} rdr opts pending-forms)
|
||||
map-count (count the-map)
|
||||
ks (take-nth 2 the-map)
|
||||
key-set (set ks)
|
||||
[end-line end-column] (ending-line-col-info rdr)]
|
||||
(when (odd? map-count)
|
||||
(err/throw-odd-map rdr start-line start-column the-map))
|
||||
(when-not (= (count key-set) (count ks))
|
||||
(err/throw-dup-keys rdr :map ks))
|
||||
(with-meta
|
||||
(if (<= map-count (* 2 (.-HASHMAP-THRESHOLD cljs.core/PersistentArrayMap)))
|
||||
(.fromArray cljs.core/PersistentArrayMap (to-array the-map) true true)
|
||||
(.fromArray cljs.core/PersistentHashMap (to-array the-map) true))
|
||||
(when start-line
|
||||
(merge
|
||||
(when-let [file (get-file-name rdr)]
|
||||
{:file file})
|
||||
{:line start-line
|
||||
:column start-column
|
||||
:end-line end-line
|
||||
:end-column end-column})))))
|
||||
|
||||
(defn- read-number
|
||||
[^not-native rdr initch]
|
||||
(loop [sb (doto (StringBuffer.) (.append initch))
|
||||
ch (read-char rdr)]
|
||||
(if (or (whitespace? ch) (macros ch) (nil? ch))
|
||||
(let [s (str sb)]
|
||||
(unread rdr ch)
|
||||
(or (match-number s)
|
||||
(err/throw-invalid-number rdr s)))
|
||||
(recur (doto sb (.append ch)) (read-char rdr)))))
|
||||
|
||||
(defn- escape-char [sb ^not-native rdr]
|
||||
(let [ch (read-char rdr)]
|
||||
(case ch
|
||||
\t "\t"
|
||||
\r "\r"
|
||||
\n "\n"
|
||||
\\ "\\"
|
||||
\" "\""
|
||||
\b "\b"
|
||||
\f "\f"
|
||||
\u (let [ch (read-char rdr)]
|
||||
(if (== -1 (js/parseInt (int ch) 16))
|
||||
(err/throw-invalid-unicode-escape rdr ch)
|
||||
(read-unicode-char rdr ch 16 4 true)))
|
||||
(if (numeric? ch)
|
||||
(let [ch (read-unicode-char rdr ch 8 3 false)]
|
||||
(if (> (int ch) 0377)
|
||||
(err/throw-bad-octal-number rdr)
|
||||
ch))
|
||||
(err/throw-bad-escape-char rdr ch)))))
|
||||
|
||||
(defn- read-string*
|
||||
[^not-native reader _ opts pending-forms]
|
||||
(loop [sb (StringBuffer.)
|
||||
ch (read-char reader)]
|
||||
(if (nil? ch)
|
||||
(err/throw-eof-reading reader :string \" sb)
|
||||
(case ch
|
||||
\\ (recur (doto sb (.append (escape-char sb reader)))
|
||||
(read-char reader))
|
||||
\" (str sb)
|
||||
(recur (doto sb (.append ch)) (read-char reader))))))
|
||||
|
||||
(defn- loc-info [rdr line column]
|
||||
(when-not (nil? line)
|
||||
(let [file (get-file-name rdr)
|
||||
filem (when-not (nil? file) {:file file})
|
||||
[end-line end-column] (ending-line-col-info rdr)
|
||||
lcm {:line line
|
||||
:column column
|
||||
:end-line end-line
|
||||
:end-column end-column}]
|
||||
(merge filem lcm))))
|
||||
|
||||
(defn- read-symbol
|
||||
[rdr initch]
|
||||
(let [[line column] (starting-line-col-info rdr)
|
||||
token (read-token rdr :symbol initch)]
|
||||
(when-not (nil? token)
|
||||
(case token
|
||||
|
||||
;; special symbols
|
||||
"nil" nil
|
||||
"true" true
|
||||
"false" false
|
||||
"/" '/
|
||||
|
||||
(let [^not-native p (parse-symbol token)]
|
||||
(if-not (nil? p)
|
||||
(let [^not-native sym (symbol (-nth p 0) (-nth p 1))]
|
||||
(-with-meta sym (loc-info rdr line column)))
|
||||
(err/throw-invalid rdr :symbol token)))))))
|
||||
|
||||
(def ^:dynamic *alias-map*
|
||||
"Map from ns alias to ns, if non-nil, it will be used to resolve read-time
|
||||
ns aliases.
|
||||
|
||||
Defaults to nil"
|
||||
nil)
|
||||
|
||||
(defn- resolve-alias [sym]
|
||||
(get *alias-map* sym))
|
||||
|
||||
(defn- resolve-ns [sym]
|
||||
(or (resolve-alias sym)
|
||||
(when-let [ns (find-ns sym)]
|
||||
(symbol (ns-name ns)))))
|
||||
|
||||
(defn- read-keyword
|
||||
[^not-native reader initch opts pending-forms]
|
||||
(let [ch (read-char reader)]
|
||||
(if-not (whitespace? ch)
|
||||
(let [token (read-token reader :keyword ch)
|
||||
^not-native s (parse-symbol token)]
|
||||
(if-not (nil? s)
|
||||
(let [ns (-nth s 0)
|
||||
name (-nth s 1)]
|
||||
(if (identical? \: (.charAt token 0))
|
||||
(if-not (nil? ns)
|
||||
(if-let [ns (resolve-alias (symbol (subs ns 1)))]
|
||||
(keyword (str ns) name)
|
||||
(err/throw-invalid reader :keyword (str \: token)))
|
||||
(if-let [ns *ns*]
|
||||
(keyword (str ns) (subs name 1))
|
||||
(err/reader-error reader "Invalid token: :" token)))
|
||||
(keyword ns name)))
|
||||
(err/throw-invalid reader :keyword (str \: token))))
|
||||
(err/throw-single-colon reader))))
|
||||
|
||||
(defn- wrapping-reader
|
||||
"Returns a function which wraps a reader in a call to sym"
|
||||
[sym]
|
||||
(fn [rdr _ opts pending-forms]
|
||||
(list sym (read* rdr true nil opts pending-forms))))
|
||||
|
||||
(defn- read-meta
|
||||
"Read metadata and return the following object with the metadata applied"
|
||||
[rdr _ opts pending-forms]
|
||||
(log-source rdr
|
||||
(let [[line column] (starting-line-col-info rdr)
|
||||
m (desugar-meta (read* rdr true nil opts pending-forms))]
|
||||
(when-not (map? m)
|
||||
(err/throw-bad-metadata rdr m))
|
||||
(let [o (read* rdr true nil opts pending-forms)]
|
||||
(if (implements? IMeta o)
|
||||
(let [m (if (and line (seq? o))
|
||||
(assoc m :line line :column column)
|
||||
m)]
|
||||
(if (implements? IWithMeta o)
|
||||
(with-meta o (merge (meta o) m))
|
||||
(reset-meta! o m)))
|
||||
(err/throw-bad-metadata-target rdr o))))))
|
||||
|
||||
(defn- read-set
|
||||
[rdr _ opts pending-forms]
|
||||
(let [[start-line start-column] (starting-line-col-info rdr)
|
||||
;; subtract 1 from start-column so it includes the # in the leading #{
|
||||
start-column (if start-column (int (dec start-column)))
|
||||
coll (read-delimited :set \} rdr opts pending-forms)
|
||||
the-set (set coll)
|
||||
[end-line end-column] (ending-line-col-info rdr)]
|
||||
(when-not (= (count coll) (count the-set))
|
||||
(err/reader-error rdr (err/throw-dup-keys rdr :set coll)))
|
||||
(with-meta the-set
|
||||
(when start-line
|
||||
(merge
|
||||
(when-let [file (get-file-name rdr)]
|
||||
{:file file})
|
||||
{:line start-line
|
||||
:column start-column
|
||||
:end-line end-line
|
||||
:end-column end-column})))))
|
||||
|
||||
(defn- read-discard
|
||||
"Read and discard the first object from rdr"
|
||||
[rdr _ opts pending-forms]
|
||||
(doto rdr
|
||||
(read* true nil opts pending-forms)))
|
||||
|
||||
(defn- read-symbolic-value
|
||||
[rdr _ opts pending-forms]
|
||||
(let [sym (read* rdr true nil opts pending-forms)]
|
||||
(case sym
|
||||
|
||||
NaN js/Number.NaN
|
||||
-Inf js/Number.NEGATIVE_INFINITY
|
||||
Inf js/Number.POSITIVE_INFINITY
|
||||
|
||||
(err/reader-error rdr (str "Invalid token: ##" sym)))))
|
||||
|
||||
(def ^:private RESERVED_FEATURES #{:else :none})
|
||||
|
||||
(defn- has-feature?
|
||||
[rdr feature opts]
|
||||
(if (keyword? feature)
|
||||
(or (= :default feature) (contains? (get opts :features) feature))
|
||||
(err/reader-error rdr "Feature should be a keyword: " feature)))
|
||||
|
||||
(defn- check-eof-error
|
||||
[form rdr first-line]
|
||||
(when (identical? form READ_EOF)
|
||||
(err/throw-eof-error rdr (and (< first-line 0) first-line))))
|
||||
|
||||
(defn- check-reserved-features
|
||||
[rdr form]
|
||||
(when (get RESERVED_FEATURES form)
|
||||
(err/reader-error rdr "Feature name " form " is reserved")))
|
||||
|
||||
(defn- check-invalid-read-cond
|
||||
[form rdr first-line]
|
||||
(when (identical? form READ_FINISHED)
|
||||
(if (< first-line 0)
|
||||
(err/reader-error rdr "read-cond requires an even number of forms")
|
||||
(err/reader-error rdr "read-cond starting on line " first-line " requires an even number of forms"))))
|
||||
|
||||
(defn- read-suppress
|
||||
"Read next form and suppress. Return nil or READ_FINISHED."
|
||||
[first-line rdr opts pending-forms]
|
||||
(binding [*suppress-read* true]
|
||||
(let [form (read* rdr false READ_EOF \) opts pending-forms)]
|
||||
(check-eof-error form rdr first-line)
|
||||
(when (identical? form READ_FINISHED)
|
||||
READ_FINISHED))))
|
||||
|
||||
(defonce ^:private NO_MATCH (js/Object.))
|
||||
|
||||
(defn- match-feature
|
||||
"Read next feature. If matched, read next form and return.
|
||||
Otherwise, read and skip next form, returning READ_FINISHED or nil."
|
||||
[first-line rdr opts pending-forms]
|
||||
(let [feature (read* rdr false READ_EOF \) opts pending-forms)]
|
||||
(check-eof-error feature rdr first-line)
|
||||
(if (= feature READ_FINISHED)
|
||||
READ_FINISHED
|
||||
(do
|
||||
(check-reserved-features rdr feature)
|
||||
(if (has-feature? rdr feature opts)
|
||||
;; feature matched, read selected form
|
||||
(doto (read* rdr false READ_EOF \) opts pending-forms)
|
||||
(check-eof-error rdr first-line)
|
||||
(check-invalid-read-cond rdr first-line))
|
||||
;; feature not matched, ignore next form
|
||||
(or (read-suppress first-line rdr opts pending-forms)
|
||||
NO_MATCH))))))
|
||||
|
||||
(defn- read-cond-delimited
|
||||
[rdr splicing opts pending-forms]
|
||||
(let [first-line (if (indexing-reader? rdr) (get-line-number rdr) -1)
|
||||
result (loop [matched NO_MATCH
|
||||
finished nil]
|
||||
(cond
|
||||
;; still looking for match, read feature+form
|
||||
(identical? matched NO_MATCH)
|
||||
(let [match (match-feature first-line rdr opts pending-forms)]
|
||||
(if (identical? match READ_FINISHED)
|
||||
READ_FINISHED
|
||||
(recur match nil)))
|
||||
|
||||
;; found match, just read and ignore the rest
|
||||
(not (identical? finished READ_FINISHED))
|
||||
(recur matched (read-suppress first-line rdr opts pending-forms))
|
||||
|
||||
:else
|
||||
matched))]
|
||||
(if (identical? result READ_FINISHED)
|
||||
rdr
|
||||
(if splicing
|
||||
(do
|
||||
(if (implements? ISequential result)
|
||||
(do
|
||||
(garray/insertArrayAt pending-forms (to-array result) 0)
|
||||
rdr)
|
||||
(err/reader-error rdr "Spliced form list in read-cond-splicing must implement ISequential")))
|
||||
result))))
|
||||
|
||||
(defn- read-cond
|
||||
[^not-native rdr _ opts pending-forms]
|
||||
(when (not (and opts (#{:allow :preserve} (:read-cond opts))))
|
||||
(throw (ex-info "Conditional read not allowed"
|
||||
{:type :runtime-exception})))
|
||||
(if-let [ch (read-char rdr)]
|
||||
(let [splicing (= ch \@)
|
||||
ch (if splicing (read-char rdr) ch)]
|
||||
(when splicing
|
||||
(when-not *read-delim*
|
||||
(err/reader-error rdr "cond-splice not in list")))
|
||||
(if-let [ch (if (whitespace? ch) (read-past whitespace? rdr) ch)]
|
||||
(if (not= ch \()
|
||||
(throw (ex-info "read-cond body must be a list"
|
||||
{:type :runtime-exception}))
|
||||
(binding [*suppress-read* (or *suppress-read* (= :preserve (:read-cond opts)))]
|
||||
(if *suppress-read*
|
||||
(reader-conditional (read-list rdr ch opts pending-forms) splicing)
|
||||
(read-cond-delimited rdr splicing opts pending-forms))))
|
||||
(err/throw-eof-in-character rdr)))
|
||||
(err/throw-eof-in-character rdr)))
|
||||
|
||||
(def ^:private ^:dynamic arg-env nil)
|
||||
|
||||
(defn- garg
|
||||
"Get a symbol for an anonymous ?argument?"
|
||||
[n]
|
||||
(symbol (str (if (== -1 n) "rest" (str "p" n))
|
||||
"__" (next-id) "#")))
|
||||
|
||||
(defn- read-fn
|
||||
[rdr _ opts pending-forms]
|
||||
(if arg-env
|
||||
(throw (ex-info "Nested #()s are not allowed" {:type :illegal-state})))
|
||||
(binding [arg-env (sorted-map)]
|
||||
(let [form (read* (doto rdr (unread \()) true nil opts pending-forms) ;; this sets bindings
|
||||
rargs (rseq arg-env)
|
||||
args (if rargs
|
||||
(let [higharg (key (first rargs))]
|
||||
(let [args (loop [i 1 args (transient [])]
|
||||
(if (> i higharg)
|
||||
(persistent! args)
|
||||
(recur (inc i) (conj! args (or (get arg-env i)
|
||||
(garg i))))))
|
||||
args (if (arg-env -1)
|
||||
(conj args '& (arg-env -1))
|
||||
args)]
|
||||
args))
|
||||
[])]
|
||||
(list 'fn* args form))))
|
||||
|
||||
(defn- register-arg
|
||||
"Registers an argument to the arg-env"
|
||||
[n]
|
||||
(if arg-env
|
||||
(if-let [ret (arg-env n)]
|
||||
ret
|
||||
(let [g (garg n)]
|
||||
(set! arg-env (assoc arg-env n g))
|
||||
g))
|
||||
(throw (ex-info "Arg literal not in #()"
|
||||
{:type :illegal-state})))) ;; should never hit this
|
||||
|
||||
(declare read-symbol)
|
||||
|
||||
(defn- read-arg
|
||||
[^not-native rdr pct opts pending-forms]
|
||||
(if (nil? arg-env)
|
||||
(read-symbol rdr pct)
|
||||
(let [ch (peek-char rdr)]
|
||||
(cond
|
||||
(or (whitespace? ch)
|
||||
(macro-terminating? ch)
|
||||
(nil? ch))
|
||||
(register-arg 1)
|
||||
|
||||
(= ch \&)
|
||||
(do (read-char rdr)
|
||||
(register-arg -1))
|
||||
|
||||
:else
|
||||
(let [n (read* rdr true nil opts pending-forms)]
|
||||
(if-not (integer? n)
|
||||
(throw (ex-info "Arg literal must be %, %& or %integer"
|
||||
{:type :illegal-state}))
|
||||
(register-arg n)))))))
|
||||
|
||||
(def ^:private ^:dynamic gensym-env nil)
|
||||
|
||||
(defn- read-unquote
|
||||
[^not-native rdr comma opts pending-forms]
|
||||
(if-let [ch (peek-char rdr)]
|
||||
(if (= \@ ch)
|
||||
((wrapping-reader 'clojure.core/unquote-splicing) (doto rdr read-char) \@ opts pending-forms)
|
||||
((wrapping-reader 'clojure.core/unquote) rdr \~ opts pending-forms))))
|
||||
|
||||
(declare syntax-quote*)
|
||||
|
||||
(defn- unquote-splicing? [form]
|
||||
(and (seq? form)
|
||||
(= (first form) 'clojure.core/unquote-splicing)))
|
||||
|
||||
(defn- unquote? [form]
|
||||
(and (seq? form)
|
||||
(= (first form) 'clojure.core/unquote)))
|
||||
|
||||
(defn- expand-list
|
||||
"Expand a list by resolving its syntax quotes and unquotes"
|
||||
[s]
|
||||
(loop [s (seq s) r (transient [])]
|
||||
(if s
|
||||
(let [item (first s)
|
||||
ret (conj! r
|
||||
(cond
|
||||
(unquote? item) (list 'clojure.core/list (second item))
|
||||
(unquote-splicing? item) (second item)
|
||||
:else (list 'clojure.core/list (syntax-quote* item))))]
|
||||
(recur (next s) ret))
|
||||
(seq (persistent! r)))))
|
||||
|
||||
(defn- flatten-map
|
||||
"Flatten a map into a seq of alternate keys and values"
|
||||
[form]
|
||||
(loop [s (seq form) key-vals (transient [])]
|
||||
(if s
|
||||
(let [e (first s)]
|
||||
(recur (next s) (-> key-vals
|
||||
(conj! (key e))
|
||||
(conj! (val e)))))
|
||||
(seq (persistent! key-vals)))))
|
||||
|
||||
(defn- register-gensym [sym]
|
||||
(if-not gensym-env
|
||||
(throw (ex-info "Gensym literal not in syntax-quote"
|
||||
{:type :illegal-state})))
|
||||
(or (get gensym-env sym)
|
||||
(let [gs (symbol (str (subs (name sym)
|
||||
0 (dec (count (name sym))))
|
||||
"__" (next-id) "__auto__"))]
|
||||
(set! gensym-env (assoc gensym-env sym gs))
|
||||
gs)))
|
||||
|
||||
(defn- add-meta [form ret]
|
||||
(if (and (implements? IWithMeta form)
|
||||
(seq (dissoc (meta form) :line :column :end-line :end-column :file :source)))
|
||||
(list 'cljs.core/with-meta ret (syntax-quote* (meta form)))
|
||||
ret))
|
||||
|
||||
(defn- syntax-quote-coll [type coll]
|
||||
(let [res (list 'cljs.core/sequence
|
||||
(cons 'cljs.core/concat
|
||||
(expand-list coll)))]
|
||||
(if type
|
||||
(list 'cljs.core/apply type res)
|
||||
res)))
|
||||
|
||||
(defn map-func
|
||||
"Decide which map type to use, array-map if less than 16 elements"
|
||||
[coll]
|
||||
(if (>= (count coll) 16)
|
||||
'cljs.core/hash-map
|
||||
'cljs.core/array-map))
|
||||
|
||||
(defn bool? [x]
|
||||
(or (instance? js/Boolean x)
|
||||
(true? x)
|
||||
(false? x)))
|
||||
|
||||
(defn ^:dynamic resolve-symbol
|
||||
"Resolve a symbol s into its fully qualified namespace version"
|
||||
[s]
|
||||
(throw (ex-info "resolve-symbol is not implemented" {:sym s})))
|
||||
|
||||
(defn- syntax-quote* [form]
|
||||
(->>
|
||||
(cond
|
||||
(special-symbol? form) (list 'quote form)
|
||||
|
||||
(symbol? form)
|
||||
(list 'quote
|
||||
(if (and (not (namespace form))
|
||||
(gstring/endsWith (name form) "#"))
|
||||
(register-gensym form)
|
||||
(let [sym (str form)]
|
||||
(if (gstring/endsWith sym ".")
|
||||
(let [csym (symbol (subs sym 0 (dec (count sym))))]
|
||||
(symbol (str (resolve-symbol csym) ".")))
|
||||
(resolve-symbol form)))))
|
||||
|
||||
(unquote? form) (second form)
|
||||
(unquote-splicing? form) (throw (ex-info "unquote-splice not in list"
|
||||
{:type :illegal-state}))
|
||||
|
||||
(coll? form)
|
||||
(cond
|
||||
|
||||
(implements? IRecord form) form
|
||||
(map? form) (syntax-quote-coll (map-func form) (flatten-map form))
|
||||
(vector? form) (list 'cljs.core/vec (syntax-quote-coll nil form))
|
||||
(set? form) (syntax-quote-coll 'cljs.core/hash-set form)
|
||||
(or (seq? form) (list? form))
|
||||
(let [seq (seq form)]
|
||||
(if seq
|
||||
(syntax-quote-coll nil seq)
|
||||
'(cljs.core/list)))
|
||||
|
||||
:else (throw (ex-info "Unknown Collection type"
|
||||
{:type :unsupported-operation})))
|
||||
|
||||
(or (keyword? form)
|
||||
(number? form)
|
||||
(string? form)
|
||||
(nil? form)
|
||||
(bool? form)
|
||||
(instance? js/RegExp form))
|
||||
form
|
||||
|
||||
:else (list 'quote form))
|
||||
(add-meta form)))
|
||||
|
||||
(defn- read-syntax-quote
|
||||
[rdr backquote opts pending-forms]
|
||||
(binding [gensym-env {}]
|
||||
(-> (read* rdr true nil opts pending-forms)
|
||||
syntax-quote*)))
|
||||
|
||||
(defn- read-namespaced-map
|
||||
[rdr _ opts pending-forms]
|
||||
(let [token (read-token rdr :namespaced-map (read-char rdr))]
|
||||
(if-let [ns (cond
|
||||
(= token ":")
|
||||
(ns-name *ns*)
|
||||
|
||||
(= \: (first token))
|
||||
(some-> token (subs 1) parse-symbol second' symbol resolve-ns)
|
||||
|
||||
:else
|
||||
(some-> token parse-symbol second'))]
|
||||
|
||||
(let [ch (read-past whitespace? rdr)]
|
||||
(if (identical? ch \{)
|
||||
(let [items (read-delimited :namespaced-map \} rdr opts pending-forms)]
|
||||
(when (odd? (count items))
|
||||
(err/throw-odd-map rdr nil nil items))
|
||||
(let [keys (namespace-keys (str ns) (take-nth 2 items))
|
||||
vals (take-nth 2 (rest items))]
|
||||
(when-not (= (count (set keys)) (count keys))
|
||||
(err/throw-dup-keys rdr :namespaced-map keys))
|
||||
(zipmap keys vals)))
|
||||
(err/throw-ns-map-no-map rdr token)))
|
||||
(err/throw-bad-ns rdr token))))
|
||||
|
||||
(defn- macros [ch]
|
||||
(case ch
|
||||
\" read-string*
|
||||
\: read-keyword
|
||||
\; read-comment
|
||||
\' (wrapping-reader 'quote)
|
||||
\@ (wrapping-reader 'clojure.core/deref)
|
||||
\^ read-meta
|
||||
\` read-syntax-quote
|
||||
\~ read-unquote
|
||||
\( read-list
|
||||
\) read-unmatched-delimiter
|
||||
\[ read-vector
|
||||
\] read-unmatched-delimiter
|
||||
\{ read-map
|
||||
\} read-unmatched-delimiter
|
||||
\\ read-char*
|
||||
\% read-arg
|
||||
\# read-dispatch
|
||||
nil))
|
||||
|
||||
(defn- dispatch-macros [ch]
|
||||
(case ch
|
||||
\^ read-meta ;; deprecated
|
||||
\' (wrapping-reader 'var)
|
||||
\( read-fn
|
||||
\{ read-set
|
||||
\< (throwing-reader "Unreadable form")
|
||||
\= (throwing-reader "read-eval not supported")
|
||||
\" read-regex
|
||||
\! read-comment
|
||||
\_ read-discard
|
||||
\? read-cond
|
||||
\: read-namespaced-map
|
||||
\# read-symbolic-value
|
||||
nil))
|
||||
|
||||
(defn- read-tagged [^not-native rdr initch opts pending-forms]
|
||||
(let [tag (read* rdr true nil opts pending-forms)]
|
||||
(if-not (symbol? tag)
|
||||
(err/throw-bad-reader-tag rdr tag))
|
||||
(if *suppress-read*
|
||||
(tagged-literal tag (read* rdr true nil opts pending-forms))
|
||||
(if-let [f (or (*data-readers* tag)
|
||||
(default-data-readers tag))]
|
||||
(f (read* rdr true nil opts pending-forms))
|
||||
(if-let [f *default-data-reader-fn*]
|
||||
(f tag (read* rdr true nil opts pending-forms))
|
||||
(err/throw-unknown-reader-tag rdr tag))))))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; Public API
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(def ^:dynamic *data-readers*
|
||||
"Map from reader tag symbols to data reader Vars.
|
||||
Reader tags without namespace qualifiers are reserved for Clojure.
|
||||
This light version of tools.reader has no implementation for default
|
||||
reader tags such as #inst and #uuid."
|
||||
{})
|
||||
|
||||
(def ^:dynamic *default-data-reader-fn*
|
||||
"When no data reader is found for a tag and *default-data-reader-fn*
|
||||
is non-nil, it will be called with two arguments, the tag and the value.
|
||||
If *default-data-reader-fn* is nil (the default value), an exception
|
||||
will be thrown for the unknown tag."
|
||||
nil)
|
||||
|
||||
(def ^:dynamic *suppress-read* false)
|
||||
|
||||
(def default-data-readers
|
||||
"Default map of data reader functions provided by Clojure.
|
||||
May be overridden by binding *data-readers*"
|
||||
{})
|
||||
|
||||
(defn- read*-internal
|
||||
[^not-native reader ^boolean eof-error? sentinel return-on opts pending-forms]
|
||||
(loop []
|
||||
(log-source reader
|
||||
(if-not ^boolean (garray/isEmpty pending-forms)
|
||||
(let [form (aget pending-forms 0)]
|
||||
(garray/removeAt pending-forms 0)
|
||||
form)
|
||||
(let [ch (read-char reader)]
|
||||
(cond
|
||||
(whitespace? ch) (recur)
|
||||
(nil? ch) (if eof-error? (err/throw-eof-error reader nil) sentinel)
|
||||
(identical? ch return-on) READ_FINISHED
|
||||
(number-literal? reader ch) (read-number reader ch)
|
||||
:else (let [f (macros ch)]
|
||||
(if-not (nil? f)
|
||||
(let [res (f reader ch opts pending-forms)]
|
||||
(if (identical? res reader)
|
||||
(recur)
|
||||
res))
|
||||
(read-symbol reader ch)))))))))
|
||||
|
||||
(defn- read*
|
||||
([reader eof-error? sentinel opts pending-forms]
|
||||
(read* reader eof-error? sentinel nil opts pending-forms))
|
||||
([^not-native reader eof-error? sentinel return-on opts pending-forms]
|
||||
(try
|
||||
(read*-internal reader eof-error? sentinel return-on opts pending-forms)
|
||||
(catch js/Error e
|
||||
(if (ex-info? e)
|
||||
(let [d (ex-data e)]
|
||||
(if (= :reader-exception (:type d))
|
||||
(throw e)
|
||||
(throw (ex-info (.-message e)
|
||||
(merge {:type :reader-exception}
|
||||
d
|
||||
(if (indexing-reader? reader)
|
||||
{:line (get-line-number reader)
|
||||
:column (get-column-number reader)
|
||||
:file (get-file-name reader)}))
|
||||
e))))
|
||||
(throw (ex-info (.-message e)
|
||||
(merge {:type :reader-exception}
|
||||
(if (indexing-reader? reader)
|
||||
{:line (get-line-number reader)
|
||||
:column (get-column-number reader)
|
||||
:file (get-file-name reader)}))
|
||||
e)))))))
|
||||
|
||||
(defn read
|
||||
"Reads the first object from an IPushbackReader.
|
||||
Returns the object read. If EOF, throws if eof-error? is true.
|
||||
Otherwise returns sentinel. If no stream is providen, *in* will be used.
|
||||
|
||||
Opts is a persistent map with valid keys:
|
||||
:read-cond - :allow to process reader conditionals, or
|
||||
:preserve to keep all branches
|
||||
:features - persistent set of feature keywords for reader conditionals
|
||||
:eof - on eof, return value unless :eofthrow, then throw.
|
||||
if not specified, will throw
|
||||
|
||||
To read data structures only, use clojure.tools.reader.edn/read
|
||||
|
||||
Note that the function signature of clojure.tools.reader/read and
|
||||
clojure.tools.reader.edn/read is not the same for eof-handling"
|
||||
{:arglists '([reader] [opts reader] [reader eof-error? eof-value])}
|
||||
([reader] (read reader true nil))
|
||||
([{eof :eof :as opts :or {eof :eofthrow}} reader] (read* reader (= eof :eofthrow) eof nil opts (to-array [])))
|
||||
([reader eof-error? sentinel] (read* reader eof-error? sentinel nil {} (to-array []))))
|
||||
|
||||
(defn read-string
|
||||
"Reads one object from the string s.
|
||||
Returns nil when s is nil or empty.
|
||||
|
||||
To read data structures only, use clojure.tools.reader.edn/read-string
|
||||
|
||||
Note that the function signature of clojure.tools.reader/read-string and
|
||||
clojure.tools.reader.edn/read-string is not the same for eof-handling"
|
||||
([s]
|
||||
(read-string {} s))
|
||||
([opts s]
|
||||
(when (and s (not (identical? s "")))
|
||||
(read opts (string-push-back-reader s)))))
|
||||
|
||||
(defn read+string
|
||||
"Like read, and taking the same args. reader must be a SourceLoggingPushbackReader.
|
||||
Returns a vector containing the object read and the (whitespace-trimmed) string read."
|
||||
([reader & args]
|
||||
(let [buf (fn [reader] (str (:buffer @(.-frames reader))))
|
||||
offset (count (buf reader))
|
||||
o (log-source reader (if (= 1 (count args))
|
||||
(read (first args) reader)
|
||||
(apply read reader args)))
|
||||
s (.trim (subs (buf reader) offset))]
|
||||
[o s])))
|
||||
File diff suppressed because one or more lines are too long
1753
resources/public/target/cljsbuild-compiler-1/cljs/tools/reader.js
Normal file
1753
resources/public/target/cljsbuild-compiler-1/cljs/tools/reader.js
Normal file
File diff suppressed because it is too large
Load diff
File diff suppressed because one or more lines are too long
|
|
@ -0,0 +1,448 @@
|
|||
;; Copyright (c) Nicola Mometto, Rich Hickey & contributors.
|
||||
;; The use and distribution terms for this software are covered by the
|
||||
;; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
|
||||
;; which can be found in the file epl-v10.html at the root of this distribution.
|
||||
;; By using this software in any fashion, you are agreeing to be bound by
|
||||
;; the terms of this license.
|
||||
;; You must not remove this notice, or any other, from this software.
|
||||
|
||||
(ns ^{:doc "An EDN reader in clojure"
|
||||
:author "Bronsa"}
|
||||
cljs.tools.reader.edn
|
||||
(:refer-clojure :exclude [read read-string char default-data-readers])
|
||||
(:require [cljs.tools.reader.impl.errors :as err]
|
||||
[cljs.tools.reader.reader-types :refer
|
||||
[read-char unread peek-char indexing-reader?
|
||||
get-line-number get-column-number get-file-name string-push-back-reader]]
|
||||
[cljs.tools.reader.impl.utils :refer
|
||||
[char ex-info? whitespace? numeric? desugar-meta namespace-keys second' char-code]]
|
||||
[cljs.tools.reader.impl.commons :refer
|
||||
[number-literal? read-past match-number parse-symbol read-comment throwing-reader]]
|
||||
[cljs.tools.reader :refer [default-data-readers]]
|
||||
[goog.string :as gstring])
|
||||
(:import goog.string.StringBuffer))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; helpers
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(declare read macros dispatch-macros)
|
||||
|
||||
(defn- ^boolean macro-terminating? [ch]
|
||||
(and (not (identical? \# ch))
|
||||
(not (identical? \' ch))
|
||||
(not (identical? \: ch))
|
||||
(macros ch)))
|
||||
|
||||
(defn- ^boolean not-constituent? [ch]
|
||||
(or (identical? \@ ch)
|
||||
(identical? \` ch)
|
||||
(identical? \~ ch)))
|
||||
|
||||
(defn- read-token
|
||||
([rdr kind initch]
|
||||
(read-token rdr kind initch true))
|
||||
([rdr kind initch validate-leading?]
|
||||
(cond
|
||||
(not initch)
|
||||
(err/throw-eof-at-start rdr kind)
|
||||
|
||||
(and validate-leading?
|
||||
(not-constituent? initch))
|
||||
(err/throw-bad-char rdr kind initch)
|
||||
|
||||
:else
|
||||
(loop [sb (StringBuffer.)
|
||||
ch (do (unread rdr initch) initch)]
|
||||
(if (or (whitespace? ch)
|
||||
(macro-terminating? ch)
|
||||
(nil? ch))
|
||||
(str sb)
|
||||
(if (not-constituent? ch)
|
||||
(err/throw-bad-char rdr kind ch)
|
||||
(recur (doto sb (.append (read-char rdr))) (peek-char rdr))))))))
|
||||
|
||||
(declare read-tagged)
|
||||
|
||||
(defn- read-dispatch
|
||||
[rdr _ opts]
|
||||
(if-let [ch (read-char rdr)]
|
||||
(if-let [dm (dispatch-macros ch)]
|
||||
(dm rdr ch opts)
|
||||
(if-let [obj (read-tagged (doto rdr (unread ch)) ch opts)]
|
||||
obj
|
||||
(err/throw-no-dispatch rdr ch)))
|
||||
(err/throw-eof-at-dispatch rdr)))
|
||||
|
||||
(defn- read-unmatched-delimiter
|
||||
[rdr ch opts]
|
||||
(err/throw-unmatch-delimiter rdr ch))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; readers
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(defn- read-unicode-char
|
||||
([token offset length base]
|
||||
(let [l (+ offset length)]
|
||||
(when-not (== (count token) l)
|
||||
(err/throw-invalid-unicode-literal nil token))
|
||||
(loop [i offset uc 0]
|
||||
(if (== i l)
|
||||
(js/String.fromCharCode uc)
|
||||
(let [d (char-code (nth token i) base)]
|
||||
(if (== d -1)
|
||||
(err/throw-invalid-unicode-digit-in-token nil (nth token i) token)
|
||||
(recur (inc i) (+ d (* uc base)))))))))
|
||||
|
||||
([rdr initch base length exact?]
|
||||
(loop [i 1 uc (char-code initch base)]
|
||||
(if (== uc -1)
|
||||
(err/throw-invalid-unicode-digit rdr initch)
|
||||
(if-not (== i length)
|
||||
(let [ch (peek-char rdr)]
|
||||
(if (or (whitespace? ch)
|
||||
(macros ch)
|
||||
(nil? ch))
|
||||
(if exact?
|
||||
(err/throw-invalid-unicode-len rdr i length)
|
||||
(js/String.fromCharCode uc))
|
||||
(let [d (char-code ch base)]
|
||||
(read-char rdr)
|
||||
(if (== d -1)
|
||||
(err/throw-invalid-unicode-digit rdr ch)
|
||||
(recur (inc i) (+ d (* uc base)))))))
|
||||
(js/String.fromCharCode uc))))))
|
||||
|
||||
(def ^:private ^:const upper-limit (.charCodeAt \uD7ff 0))
|
||||
(def ^:private ^:const lower-limit (.charCodeAt \uE000 0))
|
||||
|
||||
(defn- read-char*
|
||||
[rdr backslash opts]
|
||||
(let [ch (read-char rdr)]
|
||||
(if-not (nil? ch)
|
||||
(let [token (if (or (macro-terminating? ch)
|
||||
(not-constituent? ch)
|
||||
(whitespace? ch))
|
||||
(str ch)
|
||||
(read-token rdr :character ch false))
|
||||
token-len (count token)]
|
||||
(cond
|
||||
|
||||
(== 1 token-len) (nth token 0)
|
||||
|
||||
(identical? token "newline") \newline
|
||||
(identical? token "space") \space
|
||||
(identical? token "tab") \tab
|
||||
(identical? token "backspace") \backspace
|
||||
(identical? token "formfeed") \formfeed
|
||||
(identical? token "return") \return
|
||||
|
||||
(gstring/startsWith token "u")
|
||||
(let [c (read-unicode-char token 1 4 16)
|
||||
ic (.charCodeAt c)]
|
||||
(if (and (> ic upper-limit)
|
||||
(< ic lower-limit))
|
||||
(err/throw-invalid-character-literal rdr (.toString ic 16))
|
||||
c))
|
||||
|
||||
(gstring/startsWith token "o")
|
||||
(let [len (dec token-len)]
|
||||
(if (> len 3)
|
||||
(err/throw-invalid-octal-len rdr token)
|
||||
(let [uc (read-unicode-char token 1 len 8)]
|
||||
(if (> (int uc) 0377)
|
||||
(err/throw-bad-octal-number rdr)
|
||||
uc))))
|
||||
|
||||
:else (err/throw-unsupported-character rdr token)))
|
||||
(err/throw-eof-in-character rdr))))
|
||||
|
||||
(defn ^:private starting-line-col-info [rdr]
|
||||
(when (indexing-reader? rdr)
|
||||
[(get-line-number rdr) (int (dec (int (get-column-number rdr))))]))
|
||||
|
||||
(defn- read-delimited
|
||||
[kind delim rdr opts]
|
||||
(let [[start-line start-column] (starting-line-col-info rdr)
|
||||
delim (char delim)]
|
||||
(loop [a (transient [])]
|
||||
(let [ch (read-past whitespace? rdr)]
|
||||
(when-not ch
|
||||
(err/throw-eof-delimited rdr kind start-line start-column (count a)))
|
||||
(if (= delim (char ch))
|
||||
(persistent! a)
|
||||
(if-let [macrofn (macros ch)]
|
||||
(let [mret (macrofn rdr ch opts)]
|
||||
(recur (if-not (identical? mret rdr) (conj! a mret) a)))
|
||||
(let [o (read (doto rdr (unread ch)) true nil opts)]
|
||||
(recur (if-not (identical? o rdr) (conj! a o) a)))))))))
|
||||
|
||||
(defn- read-list
|
||||
[rdr _ opts]
|
||||
(let [the-list (read-delimited :list \) rdr opts)]
|
||||
(if (empty? the-list)
|
||||
'()
|
||||
(apply list the-list))))
|
||||
|
||||
(defn- read-vector
|
||||
[rdr _ opts]
|
||||
(read-delimited :vector \] rdr opts))
|
||||
|
||||
|
||||
(defn- read-map
|
||||
[rdr _ opts]
|
||||
(let [[start-line start-column] (starting-line-col-info rdr)
|
||||
the-map (read-delimited :map \} rdr opts)
|
||||
map-count (count the-map)
|
||||
ks (take-nth 2 the-map)
|
||||
key-set (set ks)]
|
||||
(when (odd? map-count)
|
||||
(err/throw-odd-map rdr start-line start-column the-map))
|
||||
(when-not (= (count key-set) (count ks))
|
||||
(err/throw-dup-keys rdr :map ks))
|
||||
(if (<= map-count (* 2 (.-HASHMAP-THRESHOLD cljs.core/PersistentArrayMap)))
|
||||
(.fromArray cljs.core/PersistentArrayMap (to-array the-map) true true)
|
||||
(.fromArray cljs.core/PersistentHashMap (to-array the-map) true))))
|
||||
|
||||
(defn- read-number
|
||||
[rdr initch opts]
|
||||
(loop [sb (doto (StringBuffer.) (.append initch))
|
||||
ch (read-char rdr)]
|
||||
(if (or (whitespace? ch) (macros ch) (nil? ch))
|
||||
(let [s (str sb)]
|
||||
(unread rdr ch)
|
||||
(or (match-number s)
|
||||
(err/throw-invalid-number rdr s)))
|
||||
(recur (doto sb (.append ch)) (read-char rdr)))))
|
||||
|
||||
(defn- escape-char [sb rdr]
|
||||
(let [ch (read-char rdr)]
|
||||
(case ch
|
||||
\t "\t"
|
||||
\r "\r"
|
||||
\n "\n"
|
||||
\\ "\\"
|
||||
\" "\""
|
||||
\b "\b"
|
||||
\f "\f"
|
||||
\u (let [ch (read-char rdr)]
|
||||
(if (== -1 (js/parseInt (int ch) 16))
|
||||
(err/throw-invalid-unicode-escape rdr ch)
|
||||
(read-unicode-char rdr ch 16 4 true)))
|
||||
(if (numeric? ch)
|
||||
(let [ch (read-unicode-char rdr ch 8 3 false)]
|
||||
(if (> (int ch) 0377)
|
||||
(err/throw-bad-octal-number rdr)
|
||||
ch))
|
||||
(err/throw-bad-escape-char rdr ch)))))
|
||||
|
||||
(defn- read-string*
|
||||
[rdr _ opts]
|
||||
(loop [sb (StringBuffer.)
|
||||
ch (read-char rdr)]
|
||||
(case ch
|
||||
nil (err/throw-eof-reading rdr :string \" sb)
|
||||
\\ (recur (doto sb (.append (escape-char sb rdr)))
|
||||
(read-char rdr))
|
||||
\" (str sb)
|
||||
(recur (doto sb (.append ch)) (read-char rdr)))))
|
||||
|
||||
(defn- read-symbol
|
||||
[rdr initch]
|
||||
(when-let [token (read-token rdr :symbol initch)]
|
||||
(case token
|
||||
|
||||
;; special symbols
|
||||
"nil" nil
|
||||
"true" true
|
||||
"false" false
|
||||
"/" '/
|
||||
|
||||
(or (when-let [p (parse-symbol token)]
|
||||
(symbol (p 0) (p 1)))
|
||||
(err/throw-invalid rdr :symbol token)))))
|
||||
|
||||
(defn- read-keyword
|
||||
[reader initch opts]
|
||||
(let [ch (read-char reader)]
|
||||
(if-not (whitespace? ch)
|
||||
(let [token (read-token reader :keyword ch)
|
||||
s (parse-symbol token)]
|
||||
(if (and s (== -1 (.indexOf token "::")))
|
||||
(let [ns (s 0)
|
||||
name (s 1)]
|
||||
(if (identical? \: (nth token 0))
|
||||
(err/throw-invalid reader :keyword token) ;; no ::keyword in edn
|
||||
(keyword ns name)))
|
||||
(err/throw-invalid reader :keyword token)))
|
||||
(err/throw-single-colon reader))))
|
||||
|
||||
(defn- wrapping-reader
|
||||
[sym]
|
||||
(fn [rdr _ opts]
|
||||
(list sym (read rdr true nil opts))))
|
||||
|
||||
(defn- read-meta
|
||||
[rdr _ opts]
|
||||
(let [m (desugar-meta (read rdr true nil opts))]
|
||||
(when-not (map? m)
|
||||
(err/throw-bad-metadata rdr m))
|
||||
(let [o (read rdr true nil opts)]
|
||||
(if (implements? IMeta o)
|
||||
(with-meta o (merge (meta o) m))
|
||||
(err/throw-bad-metadata-target rdr o)))))
|
||||
|
||||
(defn- read-set
|
||||
[rdr _ opts]
|
||||
(let [coll (read-delimited :set \} rdr opts)
|
||||
the-set (set coll)]
|
||||
(when-not (= (count coll) (count the-set))
|
||||
(err/throw-dup-keys rdr :set coll))
|
||||
the-set))
|
||||
|
||||
(defn- read-discard
|
||||
[rdr _ opts]
|
||||
(doto rdr
|
||||
(read true nil true)))
|
||||
|
||||
(defn- read-namespaced-map
|
||||
[rdr _ opts]
|
||||
(let [token (read-token rdr :namespaced-map (read-char rdr))]
|
||||
(if-let [ns (some-> token parse-symbol second')]
|
||||
(let [ch (read-past whitespace? rdr)]
|
||||
(if (identical? ch \{)
|
||||
(let [items (read-delimited :namespaced-map \} rdr opts)]
|
||||
(when (odd? (count items))
|
||||
(err/throw-odd-map rdr nil nil items))
|
||||
(let [keys (namespace-keys (str ns) (take-nth 2 items))
|
||||
vals (take-nth 2 (rest items))]
|
||||
(when-not (= (count (set keys)) (count keys))
|
||||
(err/throw-dup-keys rdr :namespaced-map keys))
|
||||
(zipmap keys vals)))
|
||||
(err/throw-ns-map-no-map rdr token)))
|
||||
(err/throw-bad-ns rdr token))))
|
||||
|
||||
(defn- read-symbolic-value
|
||||
[rdr _ opts]
|
||||
(let [sym (read rdr true nil opts)]
|
||||
(case sym
|
||||
|
||||
NaN js/Number.NaN
|
||||
-Inf js/Number.NEGATIVE_INFINITY
|
||||
Inf js/Number.POSITIVE_INFINITY
|
||||
|
||||
(err/reader-error rdr (str "Invalid token: ##" sym)))))
|
||||
|
||||
(defn- macros [ch]
|
||||
(case ch
|
||||
\" read-string*
|
||||
\: read-keyword
|
||||
\; read-comment
|
||||
\^ read-meta
|
||||
\( read-list
|
||||
\) read-unmatched-delimiter
|
||||
\[ read-vector
|
||||
\] read-unmatched-delimiter
|
||||
\{ read-map
|
||||
\} read-unmatched-delimiter
|
||||
\\ read-char*
|
||||
\# read-dispatch
|
||||
nil))
|
||||
|
||||
(defn- dispatch-macros [ch]
|
||||
(case ch
|
||||
\^ read-meta ;deprecated
|
||||
\{ read-set
|
||||
\< (throwing-reader "Unreadable form")
|
||||
\! read-comment
|
||||
\_ read-discard
|
||||
\: read-namespaced-map
|
||||
\# read-symbolic-value
|
||||
nil))
|
||||
|
||||
(defn- read-tagged [rdr initch opts]
|
||||
(let [tag (read rdr true nil opts)
|
||||
object (read rdr true nil opts)]
|
||||
(if-not (symbol? tag)
|
||||
(err/throw-bad-reader-tag rdr "Reader tag must be a symbol"))
|
||||
(if-let [f (or (get (:readers opts) tag)
|
||||
(default-data-readers tag))]
|
||||
(f object)
|
||||
(if-let [d (:default opts)]
|
||||
(d tag object)
|
||||
(err/throw-unknown-reader-tag rdr tag)))))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; Public API
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(defn read
|
||||
"Reads the first object from an IPushbackReader.
|
||||
Returns the object read. If EOF, throws if eof-error? is true otherwise returns eof.
|
||||
If no reader is provided, *in* will be used.
|
||||
|
||||
Reads data in the edn format (subset of Clojure data):
|
||||
http://edn-format.org
|
||||
|
||||
clojure.tools.reader.edn/read doesn't depend on dynamic Vars, all configuration
|
||||
is done by passing an opt map.
|
||||
|
||||
opts is a map that can include the following keys:
|
||||
:eof - value to return on end-of-file. When not supplied, eof throws an exception.
|
||||
:readers - a map of tag symbols to data-reader functions to be considered before default-data-readers.
|
||||
When not supplied, only the default-data-readers will be used.
|
||||
:default - A function of two args, that will, if present and no reader is found for a tag,
|
||||
be called with the tag and the value."
|
||||
([reader] (read {} reader))
|
||||
([{:keys [eof] :as opts} reader]
|
||||
(let [eof-error? (not (contains? opts :eof))]
|
||||
(read reader eof-error? eof opts)))
|
||||
([reader eof-error? eof opts]
|
||||
(try
|
||||
(loop []
|
||||
(let [ch (read-char reader)]
|
||||
(cond
|
||||
(whitespace? ch) (recur)
|
||||
(nil? ch) (if eof-error? (err/throw-eof-error reader nil) eof)
|
||||
(number-literal? reader ch) (read-number reader ch opts)
|
||||
:else (let [f (macros ch)]
|
||||
(if f
|
||||
(let [res (f reader ch opts)]
|
||||
(if (identical? res reader)
|
||||
(recur)
|
||||
res))
|
||||
(read-symbol reader ch))))))
|
||||
(catch js/Error e
|
||||
(if (ex-info? e)
|
||||
(let [d (ex-data e)]
|
||||
(if (= :reader-exception (:type d))
|
||||
(throw e)
|
||||
(throw (ex-info (.-message e)
|
||||
(merge {:type :reader-exception}
|
||||
d
|
||||
(if (indexing-reader? reader)
|
||||
{:line (get-line-number reader)
|
||||
:column (get-column-number reader)
|
||||
:file (get-file-name reader)}))
|
||||
e))))
|
||||
(throw (ex-info (.-message e)
|
||||
(merge {:type :reader-exception}
|
||||
(if (indexing-reader? reader)
|
||||
{:line (get-line-number reader)
|
||||
:column (get-column-number reader)
|
||||
:file (get-file-name reader)}))
|
||||
e)))))))
|
||||
|
||||
(defn read-string
|
||||
"Reads one object from the string s.
|
||||
Returns nil when s is nil or empty.
|
||||
|
||||
Reads data in the edn format (subset of Clojure data):
|
||||
http://edn-format.org
|
||||
|
||||
opts is a map as per clojure.tools.reader.edn/read"
|
||||
([s] (read-string {:eof nil} s))
|
||||
([opts s]
|
||||
(when (and s (not= s ""))
|
||||
(read opts (string-push-back-reader s)))))
|
||||
File diff suppressed because one or more lines are too long
|
|
@ -0,0 +1,933 @@
|
|||
// Compiled by ClojureScript 1.10.520 {}
|
||||
goog.provide('cljs.tools.reader.edn');
|
||||
goog.require('cljs.core');
|
||||
goog.require('cljs.tools.reader.impl.errors');
|
||||
goog.require('cljs.tools.reader.reader_types');
|
||||
goog.require('cljs.tools.reader.impl.utils');
|
||||
goog.require('cljs.tools.reader.impl.commons');
|
||||
goog.require('cljs.tools.reader');
|
||||
goog.require('goog.string');
|
||||
goog.require('goog.string.StringBuffer');
|
||||
|
||||
|
||||
cljs.tools.reader.edn.macro_terminating_QMARK_ = (function cljs$tools$reader$edn$macro_terminating_QMARK_(ch){
|
||||
var and__4120__auto__ = (!(("#" === ch)));
|
||||
if(and__4120__auto__){
|
||||
var and__4120__auto____$1 = (!(("'" === ch)));
|
||||
if(and__4120__auto____$1){
|
||||
var and__4120__auto____$2 = (!((":" === ch)));
|
||||
if(and__4120__auto____$2){
|
||||
return cljs.tools.reader.edn.macros.call(null,ch);
|
||||
} else {
|
||||
return and__4120__auto____$2;
|
||||
}
|
||||
} else {
|
||||
return and__4120__auto____$1;
|
||||
}
|
||||
} else {
|
||||
return and__4120__auto__;
|
||||
}
|
||||
});
|
||||
cljs.tools.reader.edn.not_constituent_QMARK_ = (function cljs$tools$reader$edn$not_constituent_QMARK_(ch){
|
||||
return ((("@" === ch)) || (("`" === ch)) || (("~" === ch)));
|
||||
});
|
||||
cljs.tools.reader.edn.read_token = (function cljs$tools$reader$edn$read_token(var_args){
|
||||
var G__21912 = arguments.length;
|
||||
switch (G__21912) {
|
||||
case 3:
|
||||
return cljs.tools.reader.edn.read_token.cljs$core$IFn$_invoke$arity$3((arguments[(0)]),(arguments[(1)]),(arguments[(2)]));
|
||||
|
||||
break;
|
||||
case 4:
|
||||
return cljs.tools.reader.edn.read_token.cljs$core$IFn$_invoke$arity$4((arguments[(0)]),(arguments[(1)]),(arguments[(2)]),(arguments[(3)]));
|
||||
|
||||
break;
|
||||
default:
|
||||
throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
cljs.tools.reader.edn.read_token.cljs$core$IFn$_invoke$arity$3 = (function (rdr,kind,initch){
|
||||
return cljs.tools.reader.edn.read_token.call(null,rdr,kind,initch,true);
|
||||
});
|
||||
|
||||
cljs.tools.reader.edn.read_token.cljs$core$IFn$_invoke$arity$4 = (function (rdr,kind,initch,validate_leading_QMARK_){
|
||||
if(cljs.core.not.call(null,initch)){
|
||||
return cljs.tools.reader.impl.errors.throw_eof_at_start.call(null,rdr,kind);
|
||||
} else {
|
||||
if(cljs.core.truth_((function (){var and__4120__auto__ = validate_leading_QMARK_;
|
||||
if(cljs.core.truth_(and__4120__auto__)){
|
||||
return cljs.tools.reader.edn.not_constituent_QMARK_.call(null,initch);
|
||||
} else {
|
||||
return and__4120__auto__;
|
||||
}
|
||||
})())){
|
||||
return cljs.tools.reader.impl.errors.throw_bad_char.call(null,rdr,kind,initch);
|
||||
} else {
|
||||
var sb = (new goog.string.StringBuffer());
|
||||
var ch = (function (){
|
||||
cljs.tools.reader.reader_types.unread.call(null,rdr,initch);
|
||||
|
||||
return initch;
|
||||
})()
|
||||
;
|
||||
while(true){
|
||||
if(((cljs.tools.reader.impl.utils.whitespace_QMARK_.call(null,ch)) || (cljs.tools.reader.edn.macro_terminating_QMARK_.call(null,ch)) || ((ch == null)))){
|
||||
return cljs.core.str.cljs$core$IFn$_invoke$arity$1(sb);
|
||||
} else {
|
||||
if(cljs.tools.reader.edn.not_constituent_QMARK_.call(null,ch)){
|
||||
return cljs.tools.reader.impl.errors.throw_bad_char.call(null,rdr,kind,ch);
|
||||
} else {
|
||||
var G__21915 = (function (){var G__21913 = sb;
|
||||
G__21913.append(cljs.tools.reader.reader_types.read_char.call(null,rdr));
|
||||
|
||||
return G__21913;
|
||||
})();
|
||||
var G__21916 = cljs.tools.reader.reader_types.peek_char.call(null,rdr);
|
||||
sb = G__21915;
|
||||
ch = G__21916;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
cljs.tools.reader.edn.read_token.cljs$lang$maxFixedArity = 4;
|
||||
|
||||
cljs.tools.reader.edn.read_dispatch = (function cljs$tools$reader$edn$read_dispatch(rdr,_,opts){
|
||||
var temp__5718__auto__ = cljs.tools.reader.reader_types.read_char.call(null,rdr);
|
||||
if(cljs.core.truth_(temp__5718__auto__)){
|
||||
var ch = temp__5718__auto__;
|
||||
var temp__5718__auto____$1 = cljs.tools.reader.edn.dispatch_macros.call(null,ch);
|
||||
if(cljs.core.truth_(temp__5718__auto____$1)){
|
||||
var dm = temp__5718__auto____$1;
|
||||
return dm.call(null,rdr,ch,opts);
|
||||
} else {
|
||||
var temp__5718__auto____$2 = cljs.tools.reader.edn.read_tagged.call(null,(function (){var G__21917 = rdr;
|
||||
cljs.tools.reader.reader_types.unread.call(null,G__21917,ch);
|
||||
|
||||
return G__21917;
|
||||
})(),ch,opts);
|
||||
if(cljs.core.truth_(temp__5718__auto____$2)){
|
||||
var obj = temp__5718__auto____$2;
|
||||
return obj;
|
||||
} else {
|
||||
return cljs.tools.reader.impl.errors.throw_no_dispatch.call(null,rdr,ch);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return cljs.tools.reader.impl.errors.throw_eof_at_dispatch.call(null,rdr);
|
||||
}
|
||||
});
|
||||
cljs.tools.reader.edn.read_unmatched_delimiter = (function cljs$tools$reader$edn$read_unmatched_delimiter(rdr,ch,opts){
|
||||
return cljs.tools.reader.impl.errors.throw_unmatch_delimiter.call(null,rdr,ch);
|
||||
});
|
||||
cljs.tools.reader.edn.read_unicode_char = (function cljs$tools$reader$edn$read_unicode_char(var_args){
|
||||
var G__21919 = arguments.length;
|
||||
switch (G__21919) {
|
||||
case 4:
|
||||
return cljs.tools.reader.edn.read_unicode_char.cljs$core$IFn$_invoke$arity$4((arguments[(0)]),(arguments[(1)]),(arguments[(2)]),(arguments[(3)]));
|
||||
|
||||
break;
|
||||
case 5:
|
||||
return cljs.tools.reader.edn.read_unicode_char.cljs$core$IFn$_invoke$arity$5((arguments[(0)]),(arguments[(1)]),(arguments[(2)]),(arguments[(3)]),(arguments[(4)]));
|
||||
|
||||
break;
|
||||
default:
|
||||
throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
cljs.tools.reader.edn.read_unicode_char.cljs$core$IFn$_invoke$arity$4 = (function (token,offset,length,base){
|
||||
var l = (offset + length);
|
||||
if((cljs.core.count.call(null,token) === l)){
|
||||
} else {
|
||||
cljs.tools.reader.impl.errors.throw_invalid_unicode_literal.call(null,null,token);
|
||||
}
|
||||
|
||||
var i = offset;
|
||||
var uc = (0);
|
||||
while(true){
|
||||
if((i === l)){
|
||||
return String.fromCharCode(uc);
|
||||
} else {
|
||||
var d = cljs.tools.reader.impl.utils.char_code.call(null,cljs.core.nth.call(null,token,i),base);
|
||||
if((d === (-1))){
|
||||
return cljs.tools.reader.impl.errors.throw_invalid_unicode_digit_in_token.call(null,null,cljs.core.nth.call(null,token,i),token);
|
||||
} else {
|
||||
var G__21921 = (i + (1));
|
||||
var G__21922 = (d + (uc * base));
|
||||
i = G__21921;
|
||||
uc = G__21922;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
cljs.tools.reader.edn.read_unicode_char.cljs$core$IFn$_invoke$arity$5 = (function (rdr,initch,base,length,exact_QMARK_){
|
||||
var i = (1);
|
||||
var uc = cljs.tools.reader.impl.utils.char_code.call(null,initch,base);
|
||||
while(true){
|
||||
if((uc === (-1))){
|
||||
return cljs.tools.reader.impl.errors.throw_invalid_unicode_digit.call(null,rdr,initch);
|
||||
} else {
|
||||
if((!((i === length)))){
|
||||
var ch = cljs.tools.reader.reader_types.peek_char.call(null,rdr);
|
||||
if(cljs.core.truth_((function (){var or__4131__auto__ = cljs.tools.reader.impl.utils.whitespace_QMARK_.call(null,ch);
|
||||
if(or__4131__auto__){
|
||||
return or__4131__auto__;
|
||||
} else {
|
||||
var or__4131__auto____$1 = cljs.tools.reader.edn.macros.call(null,ch);
|
||||
if(cljs.core.truth_(or__4131__auto____$1)){
|
||||
return or__4131__auto____$1;
|
||||
} else {
|
||||
return (ch == null);
|
||||
}
|
||||
}
|
||||
})())){
|
||||
if(cljs.core.truth_(exact_QMARK_)){
|
||||
return cljs.tools.reader.impl.errors.throw_invalid_unicode_len.call(null,rdr,i,length);
|
||||
} else {
|
||||
return String.fromCharCode(uc);
|
||||
}
|
||||
} else {
|
||||
var d = cljs.tools.reader.impl.utils.char_code.call(null,ch,base);
|
||||
cljs.tools.reader.reader_types.read_char.call(null,rdr);
|
||||
|
||||
if((d === (-1))){
|
||||
return cljs.tools.reader.impl.errors.throw_invalid_unicode_digit.call(null,rdr,ch);
|
||||
} else {
|
||||
var G__21923 = (i + (1));
|
||||
var G__21924 = (d + (uc * base));
|
||||
i = G__21923;
|
||||
uc = G__21924;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return String.fromCharCode(uc);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
cljs.tools.reader.edn.read_unicode_char.cljs$lang$maxFixedArity = 5;
|
||||
|
||||
cljs.tools.reader.edn.upper_limit = "\uD7FF".charCodeAt((0));
|
||||
cljs.tools.reader.edn.lower_limit = "\uE000".charCodeAt((0));
|
||||
cljs.tools.reader.edn.read_char_STAR_ = (function cljs$tools$reader$edn$read_char_STAR_(rdr,backslash,opts){
|
||||
var ch = cljs.tools.reader.reader_types.read_char.call(null,rdr);
|
||||
if((!((ch == null)))){
|
||||
var token = ((((cljs.tools.reader.edn.macro_terminating_QMARK_.call(null,ch)) || (cljs.tools.reader.edn.not_constituent_QMARK_.call(null,ch)) || (cljs.tools.reader.impl.utils.whitespace_QMARK_.call(null,ch))))?cljs.core.str.cljs$core$IFn$_invoke$arity$1(ch):cljs.tools.reader.edn.read_token.call(null,rdr,new cljs.core.Keyword(null,"character","character",380652989),ch,false));
|
||||
var token_len = cljs.core.count.call(null,token);
|
||||
if(((1) === token_len)){
|
||||
return cljs.core.nth.call(null,token,(0));
|
||||
} else {
|
||||
if((token === "newline")){
|
||||
return "\n";
|
||||
} else {
|
||||
if((token === "space")){
|
||||
return " ";
|
||||
} else {
|
||||
if((token === "tab")){
|
||||
return "\t";
|
||||
} else {
|
||||
if((token === "backspace")){
|
||||
return "\b";
|
||||
} else {
|
||||
if((token === "formfeed")){
|
||||
return "\f";
|
||||
} else {
|
||||
if((token === "return")){
|
||||
return "\r";
|
||||
} else {
|
||||
if(cljs.core.truth_(goog.string.startsWith(token,"u"))){
|
||||
var c = cljs.tools.reader.edn.read_unicode_char.call(null,token,(1),(4),(16));
|
||||
var ic = c.charCodeAt();
|
||||
if((((ic > cljs.tools.reader.edn.upper_limit)) && ((ic < cljs.tools.reader.edn.lower_limit)))){
|
||||
return cljs.tools.reader.impl.errors.throw_invalid_character_literal.call(null,rdr,ic.toString((16)));
|
||||
} else {
|
||||
return c;
|
||||
}
|
||||
} else {
|
||||
if(cljs.core.truth_(goog.string.startsWith(token,"o"))){
|
||||
var len = (token_len - (1));
|
||||
if((len > (3))){
|
||||
return cljs.tools.reader.impl.errors.throw_invalid_octal_len.call(null,rdr,token);
|
||||
} else {
|
||||
var uc = cljs.tools.reader.edn.read_unicode_char.call(null,token,(1),len,(8));
|
||||
if(((uc | (0)) > (255))){
|
||||
return cljs.tools.reader.impl.errors.throw_bad_octal_number.call(null,rdr);
|
||||
} else {
|
||||
return uc;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return cljs.tools.reader.impl.errors.throw_unsupported_character.call(null,rdr,token);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return cljs.tools.reader.impl.errors.throw_eof_in_character.call(null,rdr);
|
||||
}
|
||||
});
|
||||
cljs.tools.reader.edn.starting_line_col_info = (function cljs$tools$reader$edn$starting_line_col_info(rdr){
|
||||
if(cljs.tools.reader.reader_types.indexing_reader_QMARK_.call(null,rdr)){
|
||||
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [cljs.tools.reader.reader_types.get_line_number.call(null,rdr),(((cljs.tools.reader.reader_types.get_column_number.call(null,rdr) | (0)) - (1)) | (0))], null);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
cljs.tools.reader.edn.read_delimited = (function cljs$tools$reader$edn$read_delimited(kind,delim,rdr,opts){
|
||||
var vec__21925 = cljs.tools.reader.edn.starting_line_col_info.call(null,rdr);
|
||||
var start_line = cljs.core.nth.call(null,vec__21925,(0),null);
|
||||
var start_column = cljs.core.nth.call(null,vec__21925,(1),null);
|
||||
var delim__$1 = cljs.tools.reader.impl.utils.char$.call(null,delim);
|
||||
var a = cljs.core.transient$.call(null,cljs.core.PersistentVector.EMPTY);
|
||||
while(true){
|
||||
var ch = cljs.tools.reader.impl.commons.read_past.call(null,cljs.tools.reader.impl.utils.whitespace_QMARK_,rdr);
|
||||
if(cljs.core.truth_(ch)){
|
||||
} else {
|
||||
cljs.tools.reader.impl.errors.throw_eof_delimited.call(null,rdr,kind,start_line,start_column,cljs.core.count.call(null,a));
|
||||
}
|
||||
|
||||
if(cljs.core._EQ_.call(null,delim__$1,cljs.tools.reader.impl.utils.char$.call(null,ch))){
|
||||
return cljs.core.persistent_BANG_.call(null,a);
|
||||
} else {
|
||||
var temp__5718__auto__ = cljs.tools.reader.edn.macros.call(null,ch);
|
||||
if(cljs.core.truth_(temp__5718__auto__)){
|
||||
var macrofn = temp__5718__auto__;
|
||||
var mret = macrofn.call(null,rdr,ch,opts);
|
||||
var G__21929 = (((!((mret === rdr))))?cljs.core.conj_BANG_.call(null,a,mret):a);
|
||||
a = G__21929;
|
||||
continue;
|
||||
} else {
|
||||
var o = cljs.tools.reader.edn.read.call(null,(function (){var G__21928 = rdr;
|
||||
cljs.tools.reader.reader_types.unread.call(null,G__21928,ch);
|
||||
|
||||
return G__21928;
|
||||
})(),true,null,opts);
|
||||
var G__21930 = (((!((o === rdr))))?cljs.core.conj_BANG_.call(null,a,o):a);
|
||||
a = G__21930;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
});
|
||||
cljs.tools.reader.edn.read_list = (function cljs$tools$reader$edn$read_list(rdr,_,opts){
|
||||
var the_list = cljs.tools.reader.edn.read_delimited.call(null,new cljs.core.Keyword(null,"list","list",765357683),")",rdr,opts);
|
||||
if(cljs.core.empty_QMARK_.call(null,the_list)){
|
||||
return cljs.core.List.EMPTY;
|
||||
} else {
|
||||
return cljs.core.apply.call(null,cljs.core.list,the_list);
|
||||
}
|
||||
});
|
||||
cljs.tools.reader.edn.read_vector = (function cljs$tools$reader$edn$read_vector(rdr,_,opts){
|
||||
return cljs.tools.reader.edn.read_delimited.call(null,new cljs.core.Keyword(null,"vector","vector",1902966158),"]",rdr,opts);
|
||||
});
|
||||
cljs.tools.reader.edn.read_map = (function cljs$tools$reader$edn$read_map(rdr,_,opts){
|
||||
var vec__21931 = cljs.tools.reader.edn.starting_line_col_info.call(null,rdr);
|
||||
var start_line = cljs.core.nth.call(null,vec__21931,(0),null);
|
||||
var start_column = cljs.core.nth.call(null,vec__21931,(1),null);
|
||||
var the_map = cljs.tools.reader.edn.read_delimited.call(null,new cljs.core.Keyword(null,"map","map",1371690461),"}",rdr,opts);
|
||||
var map_count = cljs.core.count.call(null,the_map);
|
||||
var ks = cljs.core.take_nth.call(null,(2),the_map);
|
||||
var key_set = cljs.core.set.call(null,ks);
|
||||
if(cljs.core.odd_QMARK_.call(null,map_count)){
|
||||
cljs.tools.reader.impl.errors.throw_odd_map.call(null,rdr,start_line,start_column,the_map);
|
||||
} else {
|
||||
}
|
||||
|
||||
if(cljs.core._EQ_.call(null,cljs.core.count.call(null,key_set),cljs.core.count.call(null,ks))){
|
||||
} else {
|
||||
cljs.tools.reader.impl.errors.throw_dup_keys.call(null,rdr,new cljs.core.Keyword(null,"map","map",1371690461),ks);
|
||||
}
|
||||
|
||||
if((map_count <= ((2) * cljs.core.PersistentArrayMap.HASHMAP_THRESHOLD))){
|
||||
return cljs.core.PersistentArrayMap.fromArray(cljs.core.to_array.call(null,the_map),true,true);
|
||||
} else {
|
||||
return cljs.core.PersistentHashMap.fromArray(cljs.core.to_array.call(null,the_map),true);
|
||||
}
|
||||
});
|
||||
cljs.tools.reader.edn.read_number = (function cljs$tools$reader$edn$read_number(rdr,initch,opts){
|
||||
var sb = (function (){var G__21934 = (new goog.string.StringBuffer());
|
||||
G__21934.append(initch);
|
||||
|
||||
return G__21934;
|
||||
})();
|
||||
var ch = cljs.tools.reader.reader_types.read_char.call(null,rdr);
|
||||
while(true){
|
||||
if(cljs.core.truth_((function (){var or__4131__auto__ = cljs.tools.reader.impl.utils.whitespace_QMARK_.call(null,ch);
|
||||
if(or__4131__auto__){
|
||||
return or__4131__auto__;
|
||||
} else {
|
||||
var or__4131__auto____$1 = cljs.tools.reader.edn.macros.call(null,ch);
|
||||
if(cljs.core.truth_(or__4131__auto____$1)){
|
||||
return or__4131__auto____$1;
|
||||
} else {
|
||||
return (ch == null);
|
||||
}
|
||||
}
|
||||
})())){
|
||||
var s = cljs.core.str.cljs$core$IFn$_invoke$arity$1(sb);
|
||||
cljs.tools.reader.reader_types.unread.call(null,rdr,ch);
|
||||
|
||||
var or__4131__auto__ = cljs.tools.reader.impl.commons.match_number.call(null,s);
|
||||
if(cljs.core.truth_(or__4131__auto__)){
|
||||
return or__4131__auto__;
|
||||
} else {
|
||||
return cljs.tools.reader.impl.errors.throw_invalid_number.call(null,rdr,s);
|
||||
}
|
||||
} else {
|
||||
var G__21936 = (function (){var G__21935 = sb;
|
||||
G__21935.append(ch);
|
||||
|
||||
return G__21935;
|
||||
})();
|
||||
var G__21937 = cljs.tools.reader.reader_types.read_char.call(null,rdr);
|
||||
sb = G__21936;
|
||||
ch = G__21937;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
});
|
||||
cljs.tools.reader.edn.escape_char = (function cljs$tools$reader$edn$escape_char(sb,rdr){
|
||||
var ch = cljs.tools.reader.reader_types.read_char.call(null,rdr);
|
||||
var G__21938 = ch;
|
||||
switch (G__21938) {
|
||||
case "t":
|
||||
return "\t";
|
||||
|
||||
break;
|
||||
case "r":
|
||||
return "\r";
|
||||
|
||||
break;
|
||||
case "n":
|
||||
return "\n";
|
||||
|
||||
break;
|
||||
case "\\":
|
||||
return "\\";
|
||||
|
||||
break;
|
||||
case "\"":
|
||||
return "\"";
|
||||
|
||||
break;
|
||||
case "b":
|
||||
return "\b";
|
||||
|
||||
break;
|
||||
case "f":
|
||||
return "\f";
|
||||
|
||||
break;
|
||||
case "u":
|
||||
var ch__$1 = cljs.tools.reader.reader_types.read_char.call(null,rdr);
|
||||
if(((-1) === parseInt((ch__$1 | (0)),(16)))){
|
||||
return cljs.tools.reader.impl.errors.throw_invalid_unicode_escape.call(null,rdr,ch__$1);
|
||||
} else {
|
||||
return cljs.tools.reader.edn.read_unicode_char.call(null,rdr,ch__$1,(16),(4),true);
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
if(cljs.tools.reader.impl.utils.numeric_QMARK_.call(null,ch)){
|
||||
var ch__$1 = cljs.tools.reader.edn.read_unicode_char.call(null,rdr,ch,(8),(3),false);
|
||||
if(((ch__$1 | (0)) > (255))){
|
||||
return cljs.tools.reader.impl.errors.throw_bad_octal_number.call(null,rdr);
|
||||
} else {
|
||||
return ch__$1;
|
||||
}
|
||||
} else {
|
||||
return cljs.tools.reader.impl.errors.throw_bad_escape_char.call(null,rdr,ch);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
cljs.tools.reader.edn.read_string_STAR_ = (function cljs$tools$reader$edn$read_string_STAR_(rdr,_,opts){
|
||||
var sb = (new goog.string.StringBuffer());
|
||||
var ch = cljs.tools.reader.reader_types.read_char.call(null,rdr);
|
||||
while(true){
|
||||
var G__21940 = ch;
|
||||
if(cljs.core._EQ_.call(null,null,G__21940)){
|
||||
return cljs.tools.reader.impl.errors.throw_eof_reading.call(null,rdr,new cljs.core.Keyword(null,"string","string",-1989541586),"\"",sb);
|
||||
} else {
|
||||
if(cljs.core._EQ_.call(null,"\\",G__21940)){
|
||||
var G__21943 = (function (){var G__21941 = sb;
|
||||
G__21941.append(cljs.tools.reader.edn.escape_char.call(null,sb,rdr));
|
||||
|
||||
return G__21941;
|
||||
})();
|
||||
var G__21944 = cljs.tools.reader.reader_types.read_char.call(null,rdr);
|
||||
sb = G__21943;
|
||||
ch = G__21944;
|
||||
continue;
|
||||
} else {
|
||||
if(cljs.core._EQ_.call(null,"\"",G__21940)){
|
||||
return cljs.core.str.cljs$core$IFn$_invoke$arity$1(sb);
|
||||
} else {
|
||||
var G__21945 = (function (){var G__21942 = sb;
|
||||
G__21942.append(ch);
|
||||
|
||||
return G__21942;
|
||||
})();
|
||||
var G__21946 = cljs.tools.reader.reader_types.read_char.call(null,rdr);
|
||||
sb = G__21945;
|
||||
ch = G__21946;
|
||||
continue;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
});
|
||||
cljs.tools.reader.edn.read_symbol = (function cljs$tools$reader$edn$read_symbol(rdr,initch){
|
||||
var temp__5720__auto__ = cljs.tools.reader.edn.read_token.call(null,rdr,new cljs.core.Keyword(null,"symbol","symbol",-1038572696),initch);
|
||||
if(cljs.core.truth_(temp__5720__auto__)){
|
||||
var token = temp__5720__auto__;
|
||||
var G__21947 = token;
|
||||
switch (G__21947) {
|
||||
case "nil":
|
||||
return null;
|
||||
|
||||
break;
|
||||
case "true":
|
||||
return true;
|
||||
|
||||
break;
|
||||
case "false":
|
||||
return false;
|
||||
|
||||
break;
|
||||
case "/":
|
||||
return new cljs.core.Symbol(null,"/","/",-1371932971,null);
|
||||
|
||||
break;
|
||||
default:
|
||||
var or__4131__auto__ = (function (){var temp__5720__auto____$1 = cljs.tools.reader.impl.commons.parse_symbol.call(null,token);
|
||||
if(cljs.core.truth_(temp__5720__auto____$1)){
|
||||
var p = temp__5720__auto____$1;
|
||||
return cljs.core.symbol.call(null,p.call(null,(0)),p.call(null,(1)));
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
})();
|
||||
if(cljs.core.truth_(or__4131__auto__)){
|
||||
return or__4131__auto__;
|
||||
} else {
|
||||
return cljs.tools.reader.impl.errors.throw_invalid.call(null,rdr,new cljs.core.Keyword(null,"symbol","symbol",-1038572696),token);
|
||||
}
|
||||
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
cljs.tools.reader.edn.read_keyword = (function cljs$tools$reader$edn$read_keyword(reader,initch,opts){
|
||||
var ch = cljs.tools.reader.reader_types.read_char.call(null,reader);
|
||||
if((!(cljs.tools.reader.impl.utils.whitespace_QMARK_.call(null,ch)))){
|
||||
var token = cljs.tools.reader.edn.read_token.call(null,reader,new cljs.core.Keyword(null,"keyword","keyword",811389747),ch);
|
||||
var s = cljs.tools.reader.impl.commons.parse_symbol.call(null,token);
|
||||
if(cljs.core.truth_((function (){var and__4120__auto__ = s;
|
||||
if(cljs.core.truth_(and__4120__auto__)){
|
||||
return ((-1) === token.indexOf("::"));
|
||||
} else {
|
||||
return and__4120__auto__;
|
||||
}
|
||||
})())){
|
||||
var ns = s.call(null,(0));
|
||||
var name = s.call(null,(1));
|
||||
if((":" === cljs.core.nth.call(null,token,(0)))){
|
||||
return cljs.tools.reader.impl.errors.throw_invalid.call(null,reader,new cljs.core.Keyword(null,"keyword","keyword",811389747),token);
|
||||
} else {
|
||||
return cljs.core.keyword.call(null,ns,name);
|
||||
}
|
||||
} else {
|
||||
return cljs.tools.reader.impl.errors.throw_invalid.call(null,reader,new cljs.core.Keyword(null,"keyword","keyword",811389747),token);
|
||||
}
|
||||
} else {
|
||||
return cljs.tools.reader.impl.errors.throw_single_colon.call(null,reader);
|
||||
}
|
||||
});
|
||||
cljs.tools.reader.edn.wrapping_reader = (function cljs$tools$reader$edn$wrapping_reader(sym){
|
||||
return (function (rdr,_,opts){
|
||||
return (new cljs.core.List(null,sym,(new cljs.core.List(null,cljs.tools.reader.edn.read.call(null,rdr,true,null,opts),null,(1),null)),(2),null));
|
||||
});
|
||||
});
|
||||
cljs.tools.reader.edn.read_meta = (function cljs$tools$reader$edn$read_meta(rdr,_,opts){
|
||||
var m = cljs.tools.reader.impl.utils.desugar_meta.call(null,cljs.tools.reader.edn.read.call(null,rdr,true,null,opts));
|
||||
if(cljs.core.map_QMARK_.call(null,m)){
|
||||
} else {
|
||||
cljs.tools.reader.impl.errors.throw_bad_metadata.call(null,rdr,m);
|
||||
}
|
||||
|
||||
var o = cljs.tools.reader.edn.read.call(null,rdr,true,null,opts);
|
||||
if((((!((o == null))))?(((((o.cljs$lang$protocol_mask$partition0$ & (131072))) || ((cljs.core.PROTOCOL_SENTINEL === o.cljs$core$IMeta$))))?true:false):false)){
|
||||
return cljs.core.with_meta.call(null,o,cljs.core.merge.call(null,cljs.core.meta.call(null,o),m));
|
||||
} else {
|
||||
return cljs.tools.reader.impl.errors.throw_bad_metadata_target.call(null,rdr,o);
|
||||
}
|
||||
});
|
||||
cljs.tools.reader.edn.read_set = (function cljs$tools$reader$edn$read_set(rdr,_,opts){
|
||||
var coll = cljs.tools.reader.edn.read_delimited.call(null,new cljs.core.Keyword(null,"set","set",304602554),"}",rdr,opts);
|
||||
var the_set = cljs.core.set.call(null,coll);
|
||||
if(cljs.core._EQ_.call(null,cljs.core.count.call(null,coll),cljs.core.count.call(null,the_set))){
|
||||
} else {
|
||||
cljs.tools.reader.impl.errors.throw_dup_keys.call(null,rdr,new cljs.core.Keyword(null,"set","set",304602554),coll);
|
||||
}
|
||||
|
||||
return the_set;
|
||||
});
|
||||
cljs.tools.reader.edn.read_discard = (function cljs$tools$reader$edn$read_discard(rdr,_,opts){
|
||||
var G__21950 = rdr;
|
||||
cljs.tools.reader.edn.read.call(null,G__21950,true,null,true);
|
||||
|
||||
return G__21950;
|
||||
});
|
||||
cljs.tools.reader.edn.read_namespaced_map = (function cljs$tools$reader$edn$read_namespaced_map(rdr,_,opts){
|
||||
var token = cljs.tools.reader.edn.read_token.call(null,rdr,new cljs.core.Keyword(null,"namespaced-map","namespaced-map",1235665380),cljs.tools.reader.reader_types.read_char.call(null,rdr));
|
||||
var temp__5718__auto__ = (function (){var G__21951 = token;
|
||||
var G__21951__$1 = (((G__21951 == null))?null:cljs.tools.reader.impl.commons.parse_symbol.call(null,G__21951));
|
||||
if((G__21951__$1 == null)){
|
||||
return null;
|
||||
} else {
|
||||
return cljs.tools.reader.impl.utils.second_SINGLEQUOTE_.call(null,G__21951__$1);
|
||||
}
|
||||
})();
|
||||
if(cljs.core.truth_(temp__5718__auto__)){
|
||||
var ns = temp__5718__auto__;
|
||||
var ch = cljs.tools.reader.impl.commons.read_past.call(null,cljs.tools.reader.impl.utils.whitespace_QMARK_,rdr);
|
||||
if((ch === "{")){
|
||||
var items = cljs.tools.reader.edn.read_delimited.call(null,new cljs.core.Keyword(null,"namespaced-map","namespaced-map",1235665380),"}",rdr,opts);
|
||||
if(cljs.core.odd_QMARK_.call(null,cljs.core.count.call(null,items))){
|
||||
cljs.tools.reader.impl.errors.throw_odd_map.call(null,rdr,null,null,items);
|
||||
} else {
|
||||
}
|
||||
|
||||
var keys = cljs.tools.reader.impl.utils.namespace_keys.call(null,cljs.core.str.cljs$core$IFn$_invoke$arity$1(ns),cljs.core.take_nth.call(null,(2),items));
|
||||
var vals = cljs.core.take_nth.call(null,(2),cljs.core.rest.call(null,items));
|
||||
if(cljs.core._EQ_.call(null,cljs.core.count.call(null,cljs.core.set.call(null,keys)),cljs.core.count.call(null,keys))){
|
||||
} else {
|
||||
cljs.tools.reader.impl.errors.throw_dup_keys.call(null,rdr,new cljs.core.Keyword(null,"namespaced-map","namespaced-map",1235665380),keys);
|
||||
}
|
||||
|
||||
return cljs.core.zipmap.call(null,keys,vals);
|
||||
} else {
|
||||
return cljs.tools.reader.impl.errors.throw_ns_map_no_map.call(null,rdr,token);
|
||||
}
|
||||
} else {
|
||||
return cljs.tools.reader.impl.errors.throw_bad_ns.call(null,rdr,token);
|
||||
}
|
||||
});
|
||||
cljs.tools.reader.edn.read_symbolic_value = (function cljs$tools$reader$edn$read_symbolic_value(rdr,_,opts){
|
||||
var sym = cljs.tools.reader.edn.read.call(null,rdr,true,null,opts);
|
||||
var G__21952 = sym;
|
||||
if(cljs.core._EQ_.call(null,new cljs.core.Symbol(null,"NaN","NaN",666918153,null),G__21952)){
|
||||
return Number.NaN;
|
||||
} else {
|
||||
if(cljs.core._EQ_.call(null,new cljs.core.Symbol(null,"-Inf","-Inf",-2123243689,null),G__21952)){
|
||||
return Number.NEGATIVE_INFINITY;
|
||||
} else {
|
||||
if(cljs.core._EQ_.call(null,new cljs.core.Symbol(null,"Inf","Inf",647172781,null),G__21952)){
|
||||
return Number.POSITIVE_INFINITY;
|
||||
} else {
|
||||
return cljs.tools.reader.impl.errors.reader_error.call(null,rdr,["Invalid token: ##",cljs.core.str.cljs$core$IFn$_invoke$arity$1(sym)].join(''));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
cljs.tools.reader.edn.macros = (function cljs$tools$reader$edn$macros(ch){
|
||||
var G__21953 = ch;
|
||||
switch (G__21953) {
|
||||
case "\"":
|
||||
return cljs.tools.reader.edn.read_string_STAR_;
|
||||
|
||||
break;
|
||||
case ":":
|
||||
return cljs.tools.reader.edn.read_keyword;
|
||||
|
||||
break;
|
||||
case ";":
|
||||
return cljs.tools.reader.impl.commons.read_comment;
|
||||
|
||||
break;
|
||||
case "^":
|
||||
return cljs.tools.reader.edn.read_meta;
|
||||
|
||||
break;
|
||||
case "(":
|
||||
return cljs.tools.reader.edn.read_list;
|
||||
|
||||
break;
|
||||
case ")":
|
||||
return cljs.tools.reader.edn.read_unmatched_delimiter;
|
||||
|
||||
break;
|
||||
case "[":
|
||||
return cljs.tools.reader.edn.read_vector;
|
||||
|
||||
break;
|
||||
case "]":
|
||||
return cljs.tools.reader.edn.read_unmatched_delimiter;
|
||||
|
||||
break;
|
||||
case "{":
|
||||
return cljs.tools.reader.edn.read_map;
|
||||
|
||||
break;
|
||||
case "}":
|
||||
return cljs.tools.reader.edn.read_unmatched_delimiter;
|
||||
|
||||
break;
|
||||
case "\\":
|
||||
return cljs.tools.reader.edn.read_char_STAR_;
|
||||
|
||||
break;
|
||||
case "#":
|
||||
return cljs.tools.reader.edn.read_dispatch;
|
||||
|
||||
break;
|
||||
default:
|
||||
return null;
|
||||
|
||||
}
|
||||
});
|
||||
cljs.tools.reader.edn.dispatch_macros = (function cljs$tools$reader$edn$dispatch_macros(ch){
|
||||
var G__21955 = ch;
|
||||
switch (G__21955) {
|
||||
case "^":
|
||||
return cljs.tools.reader.edn.read_meta;
|
||||
|
||||
break;
|
||||
case "{":
|
||||
return cljs.tools.reader.edn.read_set;
|
||||
|
||||
break;
|
||||
case "<":
|
||||
return cljs.tools.reader.impl.commons.throwing_reader.call(null,"Unreadable form");
|
||||
|
||||
break;
|
||||
case "!":
|
||||
return cljs.tools.reader.impl.commons.read_comment;
|
||||
|
||||
break;
|
||||
case "_":
|
||||
return cljs.tools.reader.edn.read_discard;
|
||||
|
||||
break;
|
||||
case ":":
|
||||
return cljs.tools.reader.edn.read_namespaced_map;
|
||||
|
||||
break;
|
||||
case "#":
|
||||
return cljs.tools.reader.edn.read_symbolic_value;
|
||||
|
||||
break;
|
||||
default:
|
||||
return null;
|
||||
|
||||
}
|
||||
});
|
||||
cljs.tools.reader.edn.read_tagged = (function cljs$tools$reader$edn$read_tagged(rdr,initch,opts){
|
||||
var tag = cljs.tools.reader.edn.read.call(null,rdr,true,null,opts);
|
||||
var object = cljs.tools.reader.edn.read.call(null,rdr,true,null,opts);
|
||||
if((!((tag instanceof cljs.core.Symbol)))){
|
||||
cljs.tools.reader.impl.errors.throw_bad_reader_tag.call(null,rdr,"Reader tag must be a symbol");
|
||||
} else {
|
||||
}
|
||||
|
||||
var temp__5718__auto__ = (function (){var or__4131__auto__ = cljs.core.get.call(null,new cljs.core.Keyword(null,"readers","readers",-2118263030).cljs$core$IFn$_invoke$arity$1(opts),tag);
|
||||
if(cljs.core.truth_(or__4131__auto__)){
|
||||
return or__4131__auto__;
|
||||
} else {
|
||||
return cljs.tools.reader.default_data_readers.call(null,tag);
|
||||
}
|
||||
})();
|
||||
if(cljs.core.truth_(temp__5718__auto__)){
|
||||
var f = temp__5718__auto__;
|
||||
return f.call(null,object);
|
||||
} else {
|
||||
var temp__5718__auto____$1 = new cljs.core.Keyword(null,"default","default",-1987822328).cljs$core$IFn$_invoke$arity$1(opts);
|
||||
if(cljs.core.truth_(temp__5718__auto____$1)){
|
||||
var d = temp__5718__auto____$1;
|
||||
return d.call(null,tag,object);
|
||||
} else {
|
||||
return cljs.tools.reader.impl.errors.throw_unknown_reader_tag.call(null,rdr,tag);
|
||||
}
|
||||
}
|
||||
});
|
||||
/**
|
||||
* Reads the first object from an IPushbackReader.
|
||||
* Returns the object read. If EOF, throws if eof-error? is true otherwise returns eof.
|
||||
* If no reader is provided, *in* will be used.
|
||||
*
|
||||
* Reads data in the edn format (subset of Clojure data):
|
||||
* http://edn-format.org
|
||||
*
|
||||
* clojure.tools.reader.edn/read doesn't depend on dynamic Vars, all configuration
|
||||
* is done by passing an opt map.
|
||||
*
|
||||
* opts is a map that can include the following keys:
|
||||
* :eof - value to return on end-of-file. When not supplied, eof throws an exception.
|
||||
* :readers - a map of tag symbols to data-reader functions to be considered before default-data-readers.
|
||||
* When not supplied, only the default-data-readers will be used.
|
||||
* :default - A function of two args, that will, if present and no reader is found for a tag,
|
||||
* be called with the tag and the value.
|
||||
*/
|
||||
cljs.tools.reader.edn.read = (function cljs$tools$reader$edn$read(var_args){
|
||||
var G__21958 = arguments.length;
|
||||
switch (G__21958) {
|
||||
case 1:
|
||||
return cljs.tools.reader.edn.read.cljs$core$IFn$_invoke$arity$1((arguments[(0)]));
|
||||
|
||||
break;
|
||||
case 2:
|
||||
return cljs.tools.reader.edn.read.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)]));
|
||||
|
||||
break;
|
||||
case 4:
|
||||
return cljs.tools.reader.edn.read.cljs$core$IFn$_invoke$arity$4((arguments[(0)]),(arguments[(1)]),(arguments[(2)]),(arguments[(3)]));
|
||||
|
||||
break;
|
||||
default:
|
||||
throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
cljs.tools.reader.edn.read.cljs$core$IFn$_invoke$arity$1 = (function (reader){
|
||||
return cljs.tools.reader.edn.read.call(null,cljs.core.PersistentArrayMap.EMPTY,reader);
|
||||
});
|
||||
|
||||
cljs.tools.reader.edn.read.cljs$core$IFn$_invoke$arity$2 = (function (p__21959,reader){
|
||||
var map__21960 = p__21959;
|
||||
var map__21960__$1 = (((((!((map__21960 == null))))?(((((map__21960.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__21960.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__21960):map__21960);
|
||||
var opts = map__21960__$1;
|
||||
var eof = cljs.core.get.call(null,map__21960__$1,new cljs.core.Keyword(null,"eof","eof",-489063237));
|
||||
var eof_error_QMARK_ = (!(cljs.core.contains_QMARK_.call(null,opts,new cljs.core.Keyword(null,"eof","eof",-489063237))));
|
||||
return cljs.tools.reader.edn.read.call(null,reader,eof_error_QMARK_,eof,opts);
|
||||
});
|
||||
|
||||
cljs.tools.reader.edn.read.cljs$core$IFn$_invoke$arity$4 = (function (reader,eof_error_QMARK_,eof,opts){
|
||||
try{while(true){
|
||||
var ch = cljs.tools.reader.reader_types.read_char.call(null,reader);
|
||||
if(cljs.tools.reader.impl.utils.whitespace_QMARK_.call(null,ch)){
|
||||
continue;
|
||||
} else {
|
||||
if((ch == null)){
|
||||
if(cljs.core.truth_(eof_error_QMARK_)){
|
||||
return cljs.tools.reader.impl.errors.throw_eof_error.call(null,reader,null);
|
||||
} else {
|
||||
return eof;
|
||||
}
|
||||
} else {
|
||||
if(cljs.tools.reader.impl.commons.number_literal_QMARK_.call(null,reader,ch)){
|
||||
return cljs.tools.reader.edn.read_number.call(null,reader,ch,opts);
|
||||
} else {
|
||||
var f = cljs.tools.reader.edn.macros.call(null,ch);
|
||||
if(cljs.core.truth_(f)){
|
||||
var res = f.call(null,reader,ch,opts);
|
||||
if((res === reader)){
|
||||
continue;
|
||||
} else {
|
||||
return res;
|
||||
}
|
||||
} else {
|
||||
return cljs.tools.reader.edn.read_symbol.call(null,reader,ch);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}catch (e21962){if((e21962 instanceof Error)){
|
||||
var e = e21962;
|
||||
if(cljs.tools.reader.impl.utils.ex_info_QMARK_.call(null,e)){
|
||||
var d = cljs.core.ex_data.call(null,e);
|
||||
if(cljs.core._EQ_.call(null,new cljs.core.Keyword(null,"reader-exception","reader-exception",-1938323098),new cljs.core.Keyword(null,"type","type",1174270348).cljs$core$IFn$_invoke$arity$1(d))){
|
||||
throw e;
|
||||
} else {
|
||||
throw cljs.core.ex_info.call(null,e.message,cljs.core.merge.call(null,new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"type","type",1174270348),new cljs.core.Keyword(null,"reader-exception","reader-exception",-1938323098)], null),d,((cljs.tools.reader.reader_types.indexing_reader_QMARK_.call(null,reader))?new cljs.core.PersistentArrayMap(null, 3, [new cljs.core.Keyword(null,"line","line",212345235),cljs.tools.reader.reader_types.get_line_number.call(null,reader),new cljs.core.Keyword(null,"column","column",2078222095),cljs.tools.reader.reader_types.get_column_number.call(null,reader),new cljs.core.Keyword(null,"file","file",-1269645878),cljs.tools.reader.reader_types.get_file_name.call(null,reader)], null):null)),e);
|
||||
}
|
||||
} else {
|
||||
throw cljs.core.ex_info.call(null,e.message,cljs.core.merge.call(null,new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"type","type",1174270348),new cljs.core.Keyword(null,"reader-exception","reader-exception",-1938323098)], null),((cljs.tools.reader.reader_types.indexing_reader_QMARK_.call(null,reader))?new cljs.core.PersistentArrayMap(null, 3, [new cljs.core.Keyword(null,"line","line",212345235),cljs.tools.reader.reader_types.get_line_number.call(null,reader),new cljs.core.Keyword(null,"column","column",2078222095),cljs.tools.reader.reader_types.get_column_number.call(null,reader),new cljs.core.Keyword(null,"file","file",-1269645878),cljs.tools.reader.reader_types.get_file_name.call(null,reader)], null):null)),e);
|
||||
}
|
||||
} else {
|
||||
throw e21962;
|
||||
|
||||
}
|
||||
}});
|
||||
|
||||
cljs.tools.reader.edn.read.cljs$lang$maxFixedArity = 4;
|
||||
|
||||
/**
|
||||
* Reads one object from the string s.
|
||||
* Returns nil when s is nil or empty.
|
||||
*
|
||||
* Reads data in the edn format (subset of Clojure data):
|
||||
* http://edn-format.org
|
||||
*
|
||||
* opts is a map as per clojure.tools.reader.edn/read
|
||||
*/
|
||||
cljs.tools.reader.edn.read_string = (function cljs$tools$reader$edn$read_string(var_args){
|
||||
var G__21965 = arguments.length;
|
||||
switch (G__21965) {
|
||||
case 1:
|
||||
return cljs.tools.reader.edn.read_string.cljs$core$IFn$_invoke$arity$1((arguments[(0)]));
|
||||
|
||||
break;
|
||||
case 2:
|
||||
return cljs.tools.reader.edn.read_string.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)]));
|
||||
|
||||
break;
|
||||
default:
|
||||
throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
cljs.tools.reader.edn.read_string.cljs$core$IFn$_invoke$arity$1 = (function (s){
|
||||
return cljs.tools.reader.edn.read_string.call(null,new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"eof","eof",-489063237),null], null),s);
|
||||
});
|
||||
|
||||
cljs.tools.reader.edn.read_string.cljs$core$IFn$_invoke$arity$2 = (function (opts,s){
|
||||
if(cljs.core.truth_((function (){var and__4120__auto__ = s;
|
||||
if(cljs.core.truth_(and__4120__auto__)){
|
||||
return cljs.core.not_EQ_.call(null,s,"");
|
||||
} else {
|
||||
return and__4120__auto__;
|
||||
}
|
||||
})())){
|
||||
return cljs.tools.reader.edn.read.call(null,opts,cljs.tools.reader.reader_types.string_push_back_reader.call(null,s));
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
cljs.tools.reader.edn.read_string.cljs$lang$maxFixedArity = 2;
|
||||
|
||||
|
||||
//# sourceMappingURL=edn.js.map
|
||||
File diff suppressed because one or more lines are too long
|
|
@ -0,0 +1,131 @@
|
|||
;; Copyright (c) Nicola Mometto, Rich Hickey & contributors.
|
||||
;; The use and distribution terms for this software are covered by the
|
||||
;; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
|
||||
;; which can be found in the file epl-v10.html at the root of this distribution.
|
||||
;; By using this software in any fashion, you are agreeing to be bound by
|
||||
;; the terms of this license.
|
||||
;; You must not remove this notice, or any other, from this software.
|
||||
|
||||
(ns cljs.tools.reader.impl.commons
|
||||
(:refer-clojure :exclude [char])
|
||||
(:require
|
||||
[cljs.tools.reader.impl.errors :refer [reader-error]]
|
||||
[cljs.tools.reader.reader-types :refer [peek-char read-char]]
|
||||
[cljs.tools.reader.impl.utils :refer [numeric? newline? char]]))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; helpers
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(defn ^boolean number-literal?
|
||||
"Checks whether the reader is at the start of a number literal"
|
||||
[^not-native reader initch]
|
||||
(or (numeric? initch)
|
||||
(and (or (identical? \+ initch) (identical? \- initch))
|
||||
(numeric? (peek-char reader)))))
|
||||
|
||||
(defn read-past
|
||||
"Read until first character that doesn't match pred, returning
|
||||
char."
|
||||
[pred ^not-native rdr]
|
||||
(loop [ch (read-char rdr)]
|
||||
(if ^boolean (pred ch)
|
||||
(recur (read-char rdr))
|
||||
ch)))
|
||||
|
||||
(defn skip-line
|
||||
"Advances the reader to the end of a line. Returns the reader"
|
||||
[^not-native reader]
|
||||
(loop []
|
||||
(when-not (newline? (read-char reader))
|
||||
(recur)))
|
||||
reader)
|
||||
|
||||
(def int-pattern #"^([-+]?)(?:(0)|([1-9][0-9]*)|0[xX]([0-9A-Fa-f]+)|0([0-7]+)|([1-9][0-9]?)[rR]([0-9A-Za-z]+)|0[0-9]+)(N)?$")
|
||||
(def ratio-pattern #"([-+]?[0-9]+)/([0-9]+)")
|
||||
(def float-pattern #"([-+]?[0-9]+(\.[0-9]*)?([eE][-+]?[0-9]+)?)(M)?")
|
||||
|
||||
(defn- match-int
|
||||
[s]
|
||||
(let [m (vec (re-find int-pattern s))]
|
||||
(if-not (nil? (m 2))
|
||||
0
|
||||
(let [^boolean negate? (identical? "-" (m 1))
|
||||
a (cond
|
||||
(not (nil? (m 3))) [(m 3) 10]
|
||||
(not (nil? (m 4))) [(m 4) 16]
|
||||
(not (nil? (m 5))) [(m 5) 8]
|
||||
(not (nil? (m 7))) [(m 7) (js/parseInt (m 6))]
|
||||
:else [nil nil])
|
||||
n (a 0)]
|
||||
(when-not (nil? n)
|
||||
(let [bn (js/parseInt n (a 1))
|
||||
bn (if negate? (* -1 bn) bn)]
|
||||
(when-not (js/isNaN bn)
|
||||
bn)))))))
|
||||
|
||||
(defn- match-ratio
|
||||
[s]
|
||||
(let [m (vec (re-find ratio-pattern s))
|
||||
numerator (m 1)
|
||||
denominator (m 2)
|
||||
numerator (if (re-find #"^\+" numerator)
|
||||
(subs numerator 1)
|
||||
numerator)]
|
||||
(/ (-> numerator js/parseInt) ;;; No ratio type in cljs
|
||||
(-> denominator js/parseInt)))); So will convert to js/Number
|
||||
|
||||
(defn- match-float
|
||||
[s]
|
||||
(let [m (vec (re-find float-pattern s))]
|
||||
(if-not (nil? (m 4)) ;; for BigDecimal "10.03M", as all parsed to js/Number
|
||||
(js/parseFloat (m 1))
|
||||
(js/parseFloat s))))
|
||||
|
||||
(defn ^boolean matches? [pattern s]
|
||||
(let [[match] (re-find pattern s)]
|
||||
(identical? match s)))
|
||||
|
||||
(defn match-number [s]
|
||||
(if (matches? int-pattern s)
|
||||
(match-int s)
|
||||
(if (matches? float-pattern s)
|
||||
(match-float s)
|
||||
(when (matches? ratio-pattern s)
|
||||
(match-ratio s)))))
|
||||
|
||||
(defn parse-symbol
|
||||
"Parses a string into a vector of the namespace and symbol"
|
||||
[token]
|
||||
(when-not (or (identical? "" token)
|
||||
(true? (.test #":$" token))
|
||||
(true? (.test #"^::" token)))
|
||||
(let [ns-idx (.indexOf token "/")
|
||||
ns (when (pos? ns-idx)
|
||||
(subs token 0 ns-idx))]
|
||||
(if-not (nil? ns)
|
||||
(let [ns-idx (inc ns-idx)]
|
||||
(when-not (== ns-idx (count token))
|
||||
(let [sym (subs token ns-idx)]
|
||||
(when (and (not (numeric? (nth sym 0)))
|
||||
(not (identical? "" sym))
|
||||
(false? (.test #":$" ns))
|
||||
(or (identical? sym "/")
|
||||
(== -1 (.indexOf sym "/"))))
|
||||
[ns sym]))))
|
||||
(when (or (identical? token "/")
|
||||
(== -1 (.indexOf token "/")))
|
||||
[nil token])))))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; readers
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(defn read-comment
|
||||
[rdr & _]
|
||||
(skip-line rdr))
|
||||
|
||||
(defn throwing-reader
|
||||
[msg]
|
||||
(fn [rdr & _]
|
||||
(reader-error rdr msg)))
|
||||
File diff suppressed because one or more lines are too long
|
|
@ -0,0 +1,193 @@
|
|||
// Compiled by ClojureScript 1.10.520 {}
|
||||
goog.provide('cljs.tools.reader.impl.commons');
|
||||
goog.require('cljs.core');
|
||||
goog.require('cljs.tools.reader.impl.errors');
|
||||
goog.require('cljs.tools.reader.reader_types');
|
||||
goog.require('cljs.tools.reader.impl.utils');
|
||||
/**
|
||||
* Checks whether the reader is at the start of a number literal
|
||||
*/
|
||||
cljs.tools.reader.impl.commons.number_literal_QMARK_ = (function cljs$tools$reader$impl$commons$number_literal_QMARK_(reader,initch){
|
||||
return ((cljs.tools.reader.impl.utils.numeric_QMARK_.call(null,initch)) || (((((("+" === initch)) || (("-" === initch)))) && (cljs.tools.reader.impl.utils.numeric_QMARK_.call(null,cljs.tools.reader.reader_types.peek_char.call(null,reader))))));
|
||||
});
|
||||
/**
|
||||
* Read until first character that doesn't match pred, returning
|
||||
* char.
|
||||
*/
|
||||
cljs.tools.reader.impl.commons.read_past = (function cljs$tools$reader$impl$commons$read_past(pred,rdr){
|
||||
var ch = cljs.tools.reader.reader_types.read_char.call(null,rdr);
|
||||
while(true){
|
||||
if(pred.call(null,ch)){
|
||||
var G__21754 = cljs.tools.reader.reader_types.read_char.call(null,rdr);
|
||||
ch = G__21754;
|
||||
continue;
|
||||
} else {
|
||||
return ch;
|
||||
}
|
||||
break;
|
||||
}
|
||||
});
|
||||
/**
|
||||
* Advances the reader to the end of a line. Returns the reader
|
||||
*/
|
||||
cljs.tools.reader.impl.commons.skip_line = (function cljs$tools$reader$impl$commons$skip_line(reader){
|
||||
while(true){
|
||||
if(cljs.tools.reader.impl.utils.newline_QMARK_.call(null,cljs.tools.reader.reader_types.read_char.call(null,reader))){
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return reader;
|
||||
});
|
||||
cljs.tools.reader.impl.commons.int_pattern = /^([-+]?)(?:(0)|([1-9][0-9]*)|0[xX]([0-9A-Fa-f]+)|0([0-7]+)|([1-9][0-9]?)[rR]([0-9A-Za-z]+)|0[0-9]+)(N)?$/;
|
||||
cljs.tools.reader.impl.commons.ratio_pattern = /([-+]?[0-9]+)\/([0-9]+)/;
|
||||
cljs.tools.reader.impl.commons.float_pattern = /([-+]?[0-9]+(\.[0-9]*)?([eE][-+]?[0-9]+)?)(M)?/;
|
||||
cljs.tools.reader.impl.commons.match_int = (function cljs$tools$reader$impl$commons$match_int(s){
|
||||
var m = cljs.core.vec.call(null,cljs.core.re_find.call(null,cljs.tools.reader.impl.commons.int_pattern,s));
|
||||
if((!((m.call(null,(2)) == null)))){
|
||||
return (0);
|
||||
} else {
|
||||
var negate_QMARK_ = ("-" === m.call(null,(1)));
|
||||
var a = (((!((m.call(null,(3)) == null))))?new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [m.call(null,(3)),(10)], null):(((!((m.call(null,(4)) == null))))?new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [m.call(null,(4)),(16)], null):(((!((m.call(null,(5)) == null))))?new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [m.call(null,(5)),(8)], null):(((!((m.call(null,(7)) == null))))?new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [m.call(null,(7)),parseInt(m.call(null,(6)))], null):new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [null,null], null)
|
||||
))));
|
||||
var n = a.call(null,(0));
|
||||
if((n == null)){
|
||||
return null;
|
||||
} else {
|
||||
var bn = parseInt(n,a.call(null,(1)));
|
||||
var bn__$1 = ((negate_QMARK_)?((-1) * bn):bn);
|
||||
if(cljs.core.truth_(isNaN(bn__$1))){
|
||||
return null;
|
||||
} else {
|
||||
return bn__$1;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
cljs.tools.reader.impl.commons.match_ratio = (function cljs$tools$reader$impl$commons$match_ratio(s){
|
||||
var m = cljs.core.vec.call(null,cljs.core.re_find.call(null,cljs.tools.reader.impl.commons.ratio_pattern,s));
|
||||
var numerator = m.call(null,(1));
|
||||
var denominator = m.call(null,(2));
|
||||
var numerator__$1 = (cljs.core.truth_(cljs.core.re_find.call(null,/^\+/,numerator))?cljs.core.subs.call(null,numerator,(1)):numerator);
|
||||
return (parseInt(numerator__$1) / parseInt(denominator));
|
||||
});
|
||||
cljs.tools.reader.impl.commons.match_float = (function cljs$tools$reader$impl$commons$match_float(s){
|
||||
var m = cljs.core.vec.call(null,cljs.core.re_find.call(null,cljs.tools.reader.impl.commons.float_pattern,s));
|
||||
if((!((m.call(null,(4)) == null)))){
|
||||
return parseFloat(m.call(null,(1)));
|
||||
} else {
|
||||
return parseFloat(s);
|
||||
}
|
||||
});
|
||||
cljs.tools.reader.impl.commons.matches_QMARK_ = (function cljs$tools$reader$impl$commons$matches_QMARK_(pattern,s){
|
||||
var vec__21755 = cljs.core.re_find.call(null,pattern,s);
|
||||
var match = cljs.core.nth.call(null,vec__21755,(0),null);
|
||||
return (match === s);
|
||||
});
|
||||
cljs.tools.reader.impl.commons.match_number = (function cljs$tools$reader$impl$commons$match_number(s){
|
||||
if(cljs.tools.reader.impl.commons.matches_QMARK_.call(null,cljs.tools.reader.impl.commons.int_pattern,s)){
|
||||
return cljs.tools.reader.impl.commons.match_int.call(null,s);
|
||||
} else {
|
||||
if(cljs.tools.reader.impl.commons.matches_QMARK_.call(null,cljs.tools.reader.impl.commons.float_pattern,s)){
|
||||
return cljs.tools.reader.impl.commons.match_float.call(null,s);
|
||||
} else {
|
||||
if(cljs.tools.reader.impl.commons.matches_QMARK_.call(null,cljs.tools.reader.impl.commons.ratio_pattern,s)){
|
||||
return cljs.tools.reader.impl.commons.match_ratio.call(null,s);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
/**
|
||||
* Parses a string into a vector of the namespace and symbol
|
||||
*/
|
||||
cljs.tools.reader.impl.commons.parse_symbol = (function cljs$tools$reader$impl$commons$parse_symbol(token){
|
||||
if(((("" === token)) || (/:$/.test(token) === true) || (/^::/.test(token) === true))){
|
||||
return null;
|
||||
} else {
|
||||
var ns_idx = token.indexOf("/");
|
||||
var ns = (((ns_idx > (0)))?cljs.core.subs.call(null,token,(0),ns_idx):null);
|
||||
if((!((ns == null)))){
|
||||
var ns_idx__$1 = (ns_idx + (1));
|
||||
if((ns_idx__$1 === cljs.core.count.call(null,token))){
|
||||
return null;
|
||||
} else {
|
||||
var sym = cljs.core.subs.call(null,token,ns_idx__$1);
|
||||
if((((!(cljs.tools.reader.impl.utils.numeric_QMARK_.call(null,cljs.core.nth.call(null,sym,(0)))))) && ((!(("" === sym)))) && (/:$/.test(ns) === false) && ((((sym === "/")) || (((-1) === sym.indexOf("/"))))))){
|
||||
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [ns,sym], null);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if((((token === "/")) || (((-1) === token.indexOf("/"))))){
|
||||
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [null,token], null);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
cljs.tools.reader.impl.commons.read_comment = (function cljs$tools$reader$impl$commons$read_comment(var_args){
|
||||
var args__4736__auto__ = [];
|
||||
var len__4730__auto___21760 = arguments.length;
|
||||
var i__4731__auto___21761 = (0);
|
||||
while(true){
|
||||
if((i__4731__auto___21761 < len__4730__auto___21760)){
|
||||
args__4736__auto__.push((arguments[i__4731__auto___21761]));
|
||||
|
||||
var G__21762 = (i__4731__auto___21761 + (1));
|
||||
i__4731__auto___21761 = G__21762;
|
||||
continue;
|
||||
} else {
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
var argseq__4737__auto__ = ((((1) < args__4736__auto__.length))?(new cljs.core.IndexedSeq(args__4736__auto__.slice((1)),(0),null)):null);
|
||||
return cljs.tools.reader.impl.commons.read_comment.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),argseq__4737__auto__);
|
||||
});
|
||||
|
||||
cljs.tools.reader.impl.commons.read_comment.cljs$core$IFn$_invoke$arity$variadic = (function (rdr,_){
|
||||
return cljs.tools.reader.impl.commons.skip_line.call(null,rdr);
|
||||
});
|
||||
|
||||
cljs.tools.reader.impl.commons.read_comment.cljs$lang$maxFixedArity = (1);
|
||||
|
||||
/** @this {Function} */
|
||||
cljs.tools.reader.impl.commons.read_comment.cljs$lang$applyTo = (function (seq21758){
|
||||
var G__21759 = cljs.core.first.call(null,seq21758);
|
||||
var seq21758__$1 = cljs.core.next.call(null,seq21758);
|
||||
var self__4717__auto__ = this;
|
||||
return self__4717__auto__.cljs$core$IFn$_invoke$arity$variadic(G__21759,seq21758__$1);
|
||||
});
|
||||
|
||||
cljs.tools.reader.impl.commons.throwing_reader = (function cljs$tools$reader$impl$commons$throwing_reader(msg){
|
||||
return (function() {
|
||||
var G__21763__delegate = function (rdr,_){
|
||||
return cljs.tools.reader.impl.errors.reader_error.call(null,rdr,msg);
|
||||
};
|
||||
var G__21763 = function (rdr,var_args){
|
||||
var _ = null;
|
||||
if (arguments.length > 1) {
|
||||
var G__21764__i = 0, G__21764__a = new Array(arguments.length - 1);
|
||||
while (G__21764__i < G__21764__a.length) {G__21764__a[G__21764__i] = arguments[G__21764__i + 1]; ++G__21764__i;}
|
||||
_ = new cljs.core.IndexedSeq(G__21764__a,0,null);
|
||||
}
|
||||
return G__21763__delegate.call(this,rdr,_);};
|
||||
G__21763.cljs$lang$maxFixedArity = 1;
|
||||
G__21763.cljs$lang$applyTo = (function (arglist__21765){
|
||||
var rdr = cljs.core.first(arglist__21765);
|
||||
var _ = cljs.core.rest(arglist__21765);
|
||||
return G__21763__delegate(rdr,_);
|
||||
});
|
||||
G__21763.cljs$core$IFn$_invoke$arity$variadic = G__21763__delegate;
|
||||
return G__21763;
|
||||
})()
|
||||
;
|
||||
});
|
||||
|
||||
//# sourceMappingURL=commons.js.map
|
||||
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"\/home\/simon\/workspace\/geocsv-lite\/target\/cljsbuild-compiler-1\/cljs\/tools\/reader\/impl\/commons.js","sources":["commons.cljs"],"lineCount":193,"mappings":";AAQA;;;;;AAWA;;;uDAAA,vDAAeA,sHAEAC,OAAOC;AAFtB,AAGE,SAAI,AAACC,sDAASD,aACV,EAAK,EAAI,CAAA,QAAeA,aAAQ,CAAA,QAAgBA,eAC3C,AAACC,sDAAS,AAACC,mDAAUH;;AAEhC;;;;2CAAA,3CAAMI,8FAGHC,KAAiBC;AAHpB,AAIE,IAAOC,KAAG,AAACC,mDAAUF;;AAArB,AACE,GAAI,AAAUD,eAAKE;AACjB,eAAO,AAACC,mDAAUF;;;;AAClBC;;;;;AAEN;;;2CAAA,3CAAME,8FAEST;AAFf,AAGE;AAAA,AACE,GAAU,AAACU,sDAAS,AAACF,mDAAUR;AAA\/B;AAAA,AACE;;;;;AACJA;;AAEF,6CAAA,7CAAKW;AACL,+CAAA,\/CAAKC;AACL,+CAAA,\/CAAKC;AAEL,2CAAA,3CAAOC,8FACJC;AADH,AAEE,IAAMC,IAAE,AAACC,wBAAI,AAACC,4BAAQP,2CAAYI;AAAlC,AACE,GAAA,GAAQ,qBAAA,pBAAM,YAAA,ZAACC;AAAf;;AAEE,IAAeG,gBAAQ,CAAA,QAAgB,YAAA,ZAACH;IAClCI,IAAE,mCAAA,oGAAA,aAAA,mCAAA,oGAAA,aAAA,mCAAA,oGAAA,YAAA,mCAAA,uIAAA,AAAA,mFAAA,KAAA,3rBACC,GAAK,qBAAA,pBAAM,YAAA,ZAACJ,gHAAQ,YAAA,ZAACA,gCACrB,GAAK,qBAAA,pBAAM,YAAA,ZAACA,gHAAQ,YAAA,ZAACA,gCACrB,GAAK,qBAAA,pBAAM,YAAA,ZAACA,gHAAQ,YAAA,ZAACA,+BACrB,GAAK,qBAAA,pBAAM,YAAA,ZAACA,gHAAQ,YAAA,ZAACA,iBAAK,AAACK,SAAY,YAAA,ZAACL;;IAE3CM,IAAE,YAAA,ZAACF;AAPT,AAQE,GAAU,MAAA,LAAME;AAAhB;;AAAA,AACE,IAAMC,KAAG,AAACF,SAAYC,EAAE,YAAA,ZAACF;IACnBG,SAAG,EAAIJ,eAAQ,CAAA,OAAMI,IAAIA;AAD\/B,AAEE,oBAAU,AAACC,MAASD;AAApB;;AAAA,AACEA;;;;;AAEd,6CAAA,7CAAOE,kGACJV;AADH,AAEE,IAAMC,IAAE,AAACC,wBAAI,AAACC,4BAAQN,6CAAcG;IAC9BW,YAAU,YAAA,ZAACV;IACXW,cAAY,YAAA,ZAACX;IACbU,gBAAU,kBAAI,4BAAA,5BAACR,kCAAeQ,YAClB,mCAAA,nCAACE,yBAAKF,eACNA;AALlB,AAME,QAAG,SAAIA,TAAYL,0BAChB,SAAIM,TAAYN;;AAEvB,6CAAA,7CAAOQ,kGACJd;AADH,AAEE,IAAMC,IAAE,AAACC,wBAAI,AAACC,4BAAQL,6CAAcE;AAApC,AACE,GAAA,GAAQ,qBAAA,pBAAM,YAAA,ZAACC;AACb,OAACc,WAAc,YAAA,ZAACd;;AAChB,OAACc,WAAcf;;;AAErB,gDAAA,hDAAegB,wGAAUC,QAAQjB;AAAjC,AACE,IAAAkB,aAAc,AAACf,4BAAQc,QAAQjB;YAA\/B,AAAAmB,wBAAAD,WAAA,IAAA,\/CAAOE;AAAP,AACE,QAAYA,UAAMpB;;AAEtB,8CAAA,9CAAMqB,oGAAcrB;AAApB,AACE,GAAI,AAACgB,wDAASpB,2CAAYI;AACxB,OAACD,mDAAUC;;AACX,GAAI,AAACgB,wDAASlB,6CAAcE;AAC1B,OAACc,qDAAYd;;AACb,GAAM,AAACgB,wDAASnB,6CAAcG;AAA9B,AACE,OAACU,qDAAYV;;AADf;;;;;AAGN;;;8CAAA,9CAAMsB,oGAEHC;AAFH,AAGE,GAAU,EAAI,CAAA,OAAeA,YACf,AAAO,AAAA,UAAaA,qBACpB,AAAO,AAAA,WAAcA;AAFnC;;AAAA,AAGE,IAAMC,SAAO,cAAA,dAAUD;IACjBE,KAAG,kBAAA,2CAAA,3DAAM,UAAA,TAAMD,eACV,+BAAA,\/BAACX,yBAAKU,UAAQC;AAFzB,AAGE,GAAA,GAAQ,OAAA,NAAMC;AACZ,IAAMD,aAAO,UAAA,TAAKA;AAAlB,AACE,GAAU,CAAIA,eAAO,AAACE,0BAAMH;AAA5B;;AAAA,AACE,IAAMI,MAAI,AAACd,yBAAKU,MAAMC;AAAtB,AACE,GAAM,EAAK,GAAK,AAACrC,sDAAS,4BAAA,5BAACgC,wBAAIQ,iBACpB,GAAK,CAAA,OAAeA,YACpB,AAAQ,AAAA,UAAaF,mBACrB,EAAI,SAAA,RAAYE,kBACZ,CAAA,SAAO,YAAA,ZAAUA;AAJhC,AAAA,0FAKGF,GAAGE;;AALN;;;;AAMN,GAAM,EAAI,WAAA,VAAYJ,oBACZ,CAAA,SAAO,cAAA,dAAUA;AAD3B,AAAA,0FAAA,KAEOA;;AAFP;;;;;AAQR,AAAA,8CAAA,sDAAAK,pGAAMM;AAAN,AAAA,IAAAL,qBAAA;AAAA,AAAA,IAAAC,0BAAA,AAAA;AAAA,AAAA,IAAAC,wBAAA;;AAAA,AAAA,GAAA,CAAAA,wBAAAD;AAAA,AAAA,AAAAD,wBAAA,CAAA,UAAAE;;AAAA,eAAA,CAAAA,wBAAA;;;;AAAA;;;;AAAA,IAAAC,uBAAA,EAAA,CAAA,MAAA,AAAAH,4BAAA,AAAA,KAAAI,qBAAA,AAAAJ,yBAAA,KAAA,IAAA,OAAA;AAAA,AAAA,OAAAK,iFAAA,CAAA,UAAA,MAAAF;;;AAAA,AAAA,AAAA,mFAAA,nFAAME,8FACH3C,IAAMiD;AADT,AAEE,OAAC9C,mDAAUH;;;AAFb,AAAA,sEAAA,tEAAM2C;;AAAN;AAAA,AAAA,gEAAA,WAAAC,3EAAMD;AAAN,AAAA,IAAAE,WAAA,AAAAC,0BAAAF;IAAAA,eAAA,AAAAG,yBAAAH;AAAA,AAAA,IAAAI,qBAAA;AAAA,AAAA,OAAAA,wDAAAH,SAAAD;;;AAAA,AAIA,iDAAA,jDAAMM,0GACHC;AADH,AAEE;mCAAKnD,IAAMiD;AAAX,AACE,OAACG,qDAAapD,IAAImD;;yBADfnD;IAAMiD;;;;EAAAA;;oCAANjD,IAAMiD;;;IAANjD;IAAMiD;0BAANjD,IAAMiD","names":["cljs.tools.reader.impl.commons\/number-literal?","reader","initch","cljs.tools.reader.impl.utils\/numeric?","cljs.tools.reader.reader-types\/peek-char","cljs.tools.reader.impl.commons\/read-past","pred","rdr","ch","cljs.tools.reader.reader-types\/read-char","cljs.tools.reader.impl.commons\/skip-line","cljs.tools.reader.impl.utils\/newline?","cljs.tools.reader.impl.commons\/int-pattern","cljs.tools.reader.impl.commons\/ratio-pattern","cljs.tools.reader.impl.commons\/float-pattern","cljs.tools.reader.impl.commons\/match-int","s","m","cljs.core\/vec","cljs.core\/re-find","negate?","a","js\/parseInt","n","bn","js\/isNaN","cljs.tools.reader.impl.commons\/match-ratio","numerator","denominator","cljs.core\/subs","cljs.tools.reader.impl.commons\/match-float","js\/parseFloat","cljs.tools.reader.impl.commons\/matches?","pattern","vec__21755","cljs.core\/nth","match","cljs.tools.reader.impl.commons\/match-number","cljs.tools.reader.impl.commons\/parse-symbol","token","ns-idx","ns","cljs.core\/count","sym","var_args","args__4736__auto__","len__4730__auto__","i__4731__auto__","argseq__4737__auto__","cljs.core\/IndexedSeq","cljs.tools.reader.impl.commons\/read-comment","seq21758","G__21759","cljs.core\/first","cljs.core\/next","self__4717__auto__","_","cljs.tools.reader.impl.commons\/throwing-reader","msg","cljs.tools.reader.impl.errors\/reader-error"]}
|
||||
|
|
@ -0,0 +1,253 @@
|
|||
;; Copyright (c) Russ Olsen, Nicola Mometto, Rich Hickey & contributors.
|
||||
;; The use and distribution terms for this software are covered by the
|
||||
;; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
|
||||
;; which can be found in the file epl-v10.html at the root of this distribution.
|
||||
;; By using this software in any fashion, you are agreeing to be bound by
|
||||
;; the terms of this license.
|
||||
;; You must not remove this notice, or any other, from this software.
|
||||
|
||||
(ns cljs.tools.reader.impl.errors
|
||||
(:require [cljs.tools.reader.reader-types :as types]
|
||||
[clojure.string :as s]
|
||||
[cljs.tools.reader.impl.inspect :as i]))
|
||||
|
||||
(defn- ex-details
|
||||
[rdr ex-type]
|
||||
(let [details {:type :reader-exception
|
||||
:ex-kind ex-type}]
|
||||
(if (types/indexing-reader? rdr)
|
||||
(assoc
|
||||
details
|
||||
:file (types/get-file-name rdr)
|
||||
:line (types/get-line-number rdr)
|
||||
:col (types/get-column-number rdr))
|
||||
details)))
|
||||
|
||||
(defn- throw-ex
|
||||
"Throw an ex-info error."
|
||||
[rdr ex-type & msg]
|
||||
(let [details (ex-details rdr ex-type)
|
||||
file (:file details)
|
||||
line (:line details)
|
||||
col (:col details)
|
||||
msg1 (if file (str file " "))
|
||||
msg2 (if line (str "[line " line ", col " col "]"))
|
||||
msg3 (if (or msg1 msg2) " ")
|
||||
full-msg (apply str msg1 msg2 msg3 msg)]
|
||||
(throw (ex-info full-msg details))))
|
||||
|
||||
(defn reader-error
|
||||
"Throws an ExceptionInfo with the given message.
|
||||
If rdr is an IndexingReader, additional information about column and line number is provided"
|
||||
[rdr & msgs]
|
||||
(throw-ex rdr :reader-error (apply str msgs)))
|
||||
|
||||
(defn illegal-arg-error
|
||||
"Throws an ExceptionInfo with the given message.
|
||||
If rdr is an IndexingReader, additional information about column and line number is provided"
|
||||
[rdr & msgs]
|
||||
(throw-ex rdr :illegal-argument (apply str msgs)))
|
||||
|
||||
(defn eof-error
|
||||
"Throws an ExceptionInfo with the given message.
|
||||
If rdr is an IndexingReader, additional information about column and line number is provided"
|
||||
[rdr & msgs]
|
||||
(throw-ex rdr :eof (apply str msgs)))
|
||||
|
||||
(defn throw-eof-delimited
|
||||
([rdr kind column line] (throw-eof-delimited rdr kind line column nil))
|
||||
([rdr kind line column n]
|
||||
(eof-error
|
||||
rdr
|
||||
"Unexpected EOF while reading "
|
||||
(if n
|
||||
(str "item " n " of "))
|
||||
(name kind)
|
||||
(if line
|
||||
(str ", starting at line " line " and column " column))
|
||||
".")))
|
||||
|
||||
(defn throw-odd-map [rdr line col elements]
|
||||
(reader-error
|
||||
rdr
|
||||
"The map literal starting with "
|
||||
(i/inspect (first elements))
|
||||
(if line (str " on line " line " column " col))
|
||||
" contains "
|
||||
(count elements)
|
||||
" form(s). Map literals must contain an even number of forms."))
|
||||
|
||||
(defn throw-invalid-number [rdr token]
|
||||
(reader-error
|
||||
rdr
|
||||
"Invalid number: "
|
||||
token
|
||||
"."))
|
||||
|
||||
(defn throw-invalid-unicode-literal [rdr token]
|
||||
(throw
|
||||
(illegal-arg-error
|
||||
rdr
|
||||
"Invalid unicode literal: \\"
|
||||
token
|
||||
".")))
|
||||
|
||||
(defn throw-invalid-unicode-escape [rdr ch]
|
||||
(reader-error
|
||||
rdr
|
||||
"Invalid unicode escape: \\u"
|
||||
ch
|
||||
"."))
|
||||
|
||||
(defn throw-invalid [rdr kind token]
|
||||
(reader-error rdr "Invalid " (name kind) ": " token "."))
|
||||
|
||||
(defn throw-eof-at-start [rdr kind]
|
||||
(eof-error rdr "Unexpected EOF while reading start of " (name kind) "."))
|
||||
|
||||
(defn throw-bad-char [rdr kind ch]
|
||||
(reader-error rdr "Invalid character: " ch " found while reading " (name kind) "."))
|
||||
|
||||
(defn throw-eof-at-dispatch [rdr]
|
||||
(eof-error rdr "Unexpected EOF while reading dispatch character."))
|
||||
|
||||
(defn throw-bad-dispatch [rdr ch]
|
||||
(reader-error rdr "No dispatch macro for " ch "."))
|
||||
|
||||
(defn throw-unmatch-delimiter [rdr ch]
|
||||
(reader-error rdr "Unmatched delimiter " ch "."))
|
||||
|
||||
(defn throw-eof-reading [rdr kind & start]
|
||||
(let [init (case kind :regex "#\"" :string \")]
|
||||
(eof-error rdr "Unexpected EOF reading " (name kind) " starting " (apply str init start) ".")))
|
||||
|
||||
(defn throw-no-dispatch [rdr ch]
|
||||
(throw-bad-dispatch rdr ch))
|
||||
|
||||
(defn throw-invalid-unicode-char[rdr token]
|
||||
(reader-error
|
||||
rdr
|
||||
"Invalid unicode character \\"
|
||||
token
|
||||
"."))
|
||||
|
||||
(defn throw-invalid-unicode-digit-in-token[rdr ch token]
|
||||
(illegal-arg-error
|
||||
rdr
|
||||
"Invalid digit "
|
||||
ch
|
||||
" in unicode character \\"
|
||||
token
|
||||
"."))
|
||||
|
||||
(defn throw-invalid-unicode-digit[rdr ch]
|
||||
(illegal-arg-error
|
||||
rdr
|
||||
"Invalid digit "
|
||||
ch
|
||||
" in unicode character."))
|
||||
|
||||
(defn throw-invalid-unicode-len[rdr actual expected]
|
||||
(illegal-arg-error
|
||||
rdr
|
||||
"Invalid unicode literal. Unicode literals should be "
|
||||
expected
|
||||
"characters long. "
|
||||
"value suppled is "
|
||||
actual
|
||||
"characters long."))
|
||||
|
||||
(defn throw-invalid-character-literal[rdr token]
|
||||
(reader-error rdr "Invalid character literal \\u" token "."))
|
||||
|
||||
(defn throw-invalid-octal-len[rdr token]
|
||||
(reader-error
|
||||
rdr
|
||||
"Invalid octal escape sequence in a character literal:"
|
||||
token
|
||||
". Octal escape sequences must be 3 or fewer digits."))
|
||||
|
||||
(defn throw-bad-octal-number [rdr]
|
||||
(reader-error rdr "Octal escape sequence must be in range [0, 377]."))
|
||||
|
||||
(defn throw-unsupported-character[rdr token]
|
||||
(reader-error
|
||||
rdr
|
||||
"Unsupported character: "
|
||||
token
|
||||
"."))
|
||||
|
||||
(defn throw-eof-in-character [rdr]
|
||||
(eof-error
|
||||
rdr
|
||||
"Unexpected EOF while reading character."))
|
||||
|
||||
(defn throw-bad-escape-char [rdr ch]
|
||||
(reader-error rdr "Unsupported escape character: \\" ch "."))
|
||||
|
||||
(defn throw-single-colon [rdr]
|
||||
(reader-error rdr "A single colon is not a valid keyword."))
|
||||
|
||||
(defn throw-bad-metadata [rdr x]
|
||||
(reader-error
|
||||
rdr
|
||||
"Metadata cannot be "
|
||||
(i/inspect x)
|
||||
". Metadata must be a Symbol, Keyword, String or Map."))
|
||||
|
||||
(defn throw-bad-metadata-target [rdr target]
|
||||
(reader-error
|
||||
rdr
|
||||
"Metadata can not be applied to "
|
||||
(i/inspect target)
|
||||
". "
|
||||
"Metadata can only be applied to IMetas."))
|
||||
|
||||
(defn throw-feature-not-keyword [rdr feature]
|
||||
(reader-error
|
||||
rdr
|
||||
"Feature cannot be "
|
||||
(i/inspect feature)
|
||||
" Features must be keywords."))
|
||||
|
||||
(defn throw-ns-map-no-map [rdr ns-name]
|
||||
(reader-error rdr "Namespaced map with namespace " ns-name " does not specify a map."))
|
||||
|
||||
(defn throw-bad-ns [rdr ns-name]
|
||||
(reader-error rdr "Invalid value used as namespace in namespaced map: " ns-name "."))
|
||||
|
||||
(defn throw-bad-reader-tag [rdr tag]
|
||||
(reader-error
|
||||
rdr
|
||||
"Invalid reader tag: "
|
||||
(i/inspect tag)
|
||||
". Reader tags must be symbols."))
|
||||
|
||||
(defn throw-unknown-reader-tag [rdr tag]
|
||||
(reader-error
|
||||
rdr
|
||||
"No reader function for tag "
|
||||
(i/inspect tag)
|
||||
"."))
|
||||
|
||||
(defn- duplicate-keys-error [msg coll]
|
||||
(letfn [(duplicates [seq]
|
||||
(for [[id freq] (frequencies seq)
|
||||
:when (> freq 1)]
|
||||
id))]
|
||||
(let [dups (duplicates coll)]
|
||||
(apply str msg
|
||||
(when (> (count dups) 1) "s")
|
||||
": " (interpose ", " dups)))))
|
||||
|
||||
(defn throw-dup-keys [rdr kind ks]
|
||||
(reader-error
|
||||
rdr
|
||||
(duplicate-keys-error
|
||||
(str (s/capitalize (name kind)) " literal contains duplicate key")
|
||||
ks)))
|
||||
|
||||
(defn throw-eof-error [rdr line]
|
||||
(if line
|
||||
(eof-error rdr "EOF while reading, starting at line " line ".")
|
||||
(eof-error rdr "EOF while reading.")))
|
||||
File diff suppressed because one or more lines are too long
|
|
@ -0,0 +1,423 @@
|
|||
// Compiled by ClojureScript 1.10.520 {}
|
||||
goog.provide('cljs.tools.reader.impl.errors');
|
||||
goog.require('cljs.core');
|
||||
goog.require('cljs.tools.reader.reader_types');
|
||||
goog.require('clojure.string');
|
||||
goog.require('cljs.tools.reader.impl.inspect');
|
||||
cljs.tools.reader.impl.errors.ex_details = (function cljs$tools$reader$impl$errors$ex_details(rdr,ex_type){
|
||||
var details = new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"type","type",1174270348),new cljs.core.Keyword(null,"reader-exception","reader-exception",-1938323098),new cljs.core.Keyword(null,"ex-kind","ex-kind",1581199296),ex_type], null);
|
||||
if(cljs.tools.reader.reader_types.indexing_reader_QMARK_.call(null,rdr)){
|
||||
return cljs.core.assoc.call(null,details,new cljs.core.Keyword(null,"file","file",-1269645878),cljs.tools.reader.reader_types.get_file_name.call(null,rdr),new cljs.core.Keyword(null,"line","line",212345235),cljs.tools.reader.reader_types.get_line_number.call(null,rdr),new cljs.core.Keyword(null,"col","col",-1959363084),cljs.tools.reader.reader_types.get_column_number.call(null,rdr));
|
||||
} else {
|
||||
return details;
|
||||
}
|
||||
});
|
||||
/**
|
||||
* Throw an ex-info error.
|
||||
*/
|
||||
cljs.tools.reader.impl.errors.throw_ex = (function cljs$tools$reader$impl$errors$throw_ex(var_args){
|
||||
var args__4736__auto__ = [];
|
||||
var len__4730__auto___21700 = arguments.length;
|
||||
var i__4731__auto___21701 = (0);
|
||||
while(true){
|
||||
if((i__4731__auto___21701 < len__4730__auto___21700)){
|
||||
args__4736__auto__.push((arguments[i__4731__auto___21701]));
|
||||
|
||||
var G__21702 = (i__4731__auto___21701 + (1));
|
||||
i__4731__auto___21701 = G__21702;
|
||||
continue;
|
||||
} else {
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
var argseq__4737__auto__ = ((((2) < args__4736__auto__.length))?(new cljs.core.IndexedSeq(args__4736__auto__.slice((2)),(0),null)):null);
|
||||
return cljs.tools.reader.impl.errors.throw_ex.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),(arguments[(1)]),argseq__4737__auto__);
|
||||
});
|
||||
|
||||
cljs.tools.reader.impl.errors.throw_ex.cljs$core$IFn$_invoke$arity$variadic = (function (rdr,ex_type,msg){
|
||||
var details = cljs.tools.reader.impl.errors.ex_details.call(null,rdr,ex_type);
|
||||
var file = new cljs.core.Keyword(null,"file","file",-1269645878).cljs$core$IFn$_invoke$arity$1(details);
|
||||
var line = new cljs.core.Keyword(null,"line","line",212345235).cljs$core$IFn$_invoke$arity$1(details);
|
||||
var col = new cljs.core.Keyword(null,"col","col",-1959363084).cljs$core$IFn$_invoke$arity$1(details);
|
||||
var msg1 = (cljs.core.truth_(file)?[cljs.core.str.cljs$core$IFn$_invoke$arity$1(file)," "].join(''):null);
|
||||
var msg2 = (cljs.core.truth_(line)?["[line ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(line),", col ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(col),"]"].join(''):null);
|
||||
var msg3 = (cljs.core.truth_((function (){var or__4131__auto__ = msg1;
|
||||
if(cljs.core.truth_(or__4131__auto__)){
|
||||
return or__4131__auto__;
|
||||
} else {
|
||||
return msg2;
|
||||
}
|
||||
})())?" ":null);
|
||||
var full_msg = cljs.core.apply.call(null,cljs.core.str,msg1,msg2,msg3,msg);
|
||||
throw cljs.core.ex_info.call(null,full_msg,details);
|
||||
});
|
||||
|
||||
cljs.tools.reader.impl.errors.throw_ex.cljs$lang$maxFixedArity = (2);
|
||||
|
||||
/** @this {Function} */
|
||||
cljs.tools.reader.impl.errors.throw_ex.cljs$lang$applyTo = (function (seq21697){
|
||||
var G__21698 = cljs.core.first.call(null,seq21697);
|
||||
var seq21697__$1 = cljs.core.next.call(null,seq21697);
|
||||
var G__21699 = cljs.core.first.call(null,seq21697__$1);
|
||||
var seq21697__$2 = cljs.core.next.call(null,seq21697__$1);
|
||||
var self__4717__auto__ = this;
|
||||
return self__4717__auto__.cljs$core$IFn$_invoke$arity$variadic(G__21698,G__21699,seq21697__$2);
|
||||
});
|
||||
|
||||
/**
|
||||
* Throws an ExceptionInfo with the given message.
|
||||
* If rdr is an IndexingReader, additional information about column and line number is provided
|
||||
*/
|
||||
cljs.tools.reader.impl.errors.reader_error = (function cljs$tools$reader$impl$errors$reader_error(var_args){
|
||||
var args__4736__auto__ = [];
|
||||
var len__4730__auto___21705 = arguments.length;
|
||||
var i__4731__auto___21706 = (0);
|
||||
while(true){
|
||||
if((i__4731__auto___21706 < len__4730__auto___21705)){
|
||||
args__4736__auto__.push((arguments[i__4731__auto___21706]));
|
||||
|
||||
var G__21707 = (i__4731__auto___21706 + (1));
|
||||
i__4731__auto___21706 = G__21707;
|
||||
continue;
|
||||
} else {
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
var argseq__4737__auto__ = ((((1) < args__4736__auto__.length))?(new cljs.core.IndexedSeq(args__4736__auto__.slice((1)),(0),null)):null);
|
||||
return cljs.tools.reader.impl.errors.reader_error.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),argseq__4737__auto__);
|
||||
});
|
||||
|
||||
cljs.tools.reader.impl.errors.reader_error.cljs$core$IFn$_invoke$arity$variadic = (function (rdr,msgs){
|
||||
return cljs.tools.reader.impl.errors.throw_ex.call(null,rdr,new cljs.core.Keyword(null,"reader-error","reader-error",1610253121),cljs.core.apply.call(null,cljs.core.str,msgs));
|
||||
});
|
||||
|
||||
cljs.tools.reader.impl.errors.reader_error.cljs$lang$maxFixedArity = (1);
|
||||
|
||||
/** @this {Function} */
|
||||
cljs.tools.reader.impl.errors.reader_error.cljs$lang$applyTo = (function (seq21703){
|
||||
var G__21704 = cljs.core.first.call(null,seq21703);
|
||||
var seq21703__$1 = cljs.core.next.call(null,seq21703);
|
||||
var self__4717__auto__ = this;
|
||||
return self__4717__auto__.cljs$core$IFn$_invoke$arity$variadic(G__21704,seq21703__$1);
|
||||
});
|
||||
|
||||
/**
|
||||
* Throws an ExceptionInfo with the given message.
|
||||
* If rdr is an IndexingReader, additional information about column and line number is provided
|
||||
*/
|
||||
cljs.tools.reader.impl.errors.illegal_arg_error = (function cljs$tools$reader$impl$errors$illegal_arg_error(var_args){
|
||||
var args__4736__auto__ = [];
|
||||
var len__4730__auto___21710 = arguments.length;
|
||||
var i__4731__auto___21711 = (0);
|
||||
while(true){
|
||||
if((i__4731__auto___21711 < len__4730__auto___21710)){
|
||||
args__4736__auto__.push((arguments[i__4731__auto___21711]));
|
||||
|
||||
var G__21712 = (i__4731__auto___21711 + (1));
|
||||
i__4731__auto___21711 = G__21712;
|
||||
continue;
|
||||
} else {
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
var argseq__4737__auto__ = ((((1) < args__4736__auto__.length))?(new cljs.core.IndexedSeq(args__4736__auto__.slice((1)),(0),null)):null);
|
||||
return cljs.tools.reader.impl.errors.illegal_arg_error.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),argseq__4737__auto__);
|
||||
});
|
||||
|
||||
cljs.tools.reader.impl.errors.illegal_arg_error.cljs$core$IFn$_invoke$arity$variadic = (function (rdr,msgs){
|
||||
return cljs.tools.reader.impl.errors.throw_ex.call(null,rdr,new cljs.core.Keyword(null,"illegal-argument","illegal-argument",-1845493170),cljs.core.apply.call(null,cljs.core.str,msgs));
|
||||
});
|
||||
|
||||
cljs.tools.reader.impl.errors.illegal_arg_error.cljs$lang$maxFixedArity = (1);
|
||||
|
||||
/** @this {Function} */
|
||||
cljs.tools.reader.impl.errors.illegal_arg_error.cljs$lang$applyTo = (function (seq21708){
|
||||
var G__21709 = cljs.core.first.call(null,seq21708);
|
||||
var seq21708__$1 = cljs.core.next.call(null,seq21708);
|
||||
var self__4717__auto__ = this;
|
||||
return self__4717__auto__.cljs$core$IFn$_invoke$arity$variadic(G__21709,seq21708__$1);
|
||||
});
|
||||
|
||||
/**
|
||||
* Throws an ExceptionInfo with the given message.
|
||||
* If rdr is an IndexingReader, additional information about column and line number is provided
|
||||
*/
|
||||
cljs.tools.reader.impl.errors.eof_error = (function cljs$tools$reader$impl$errors$eof_error(var_args){
|
||||
var args__4736__auto__ = [];
|
||||
var len__4730__auto___21715 = arguments.length;
|
||||
var i__4731__auto___21716 = (0);
|
||||
while(true){
|
||||
if((i__4731__auto___21716 < len__4730__auto___21715)){
|
||||
args__4736__auto__.push((arguments[i__4731__auto___21716]));
|
||||
|
||||
var G__21717 = (i__4731__auto___21716 + (1));
|
||||
i__4731__auto___21716 = G__21717;
|
||||
continue;
|
||||
} else {
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
var argseq__4737__auto__ = ((((1) < args__4736__auto__.length))?(new cljs.core.IndexedSeq(args__4736__auto__.slice((1)),(0),null)):null);
|
||||
return cljs.tools.reader.impl.errors.eof_error.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),argseq__4737__auto__);
|
||||
});
|
||||
|
||||
cljs.tools.reader.impl.errors.eof_error.cljs$core$IFn$_invoke$arity$variadic = (function (rdr,msgs){
|
||||
return cljs.tools.reader.impl.errors.throw_ex.call(null,rdr,new cljs.core.Keyword(null,"eof","eof",-489063237),cljs.core.apply.call(null,cljs.core.str,msgs));
|
||||
});
|
||||
|
||||
cljs.tools.reader.impl.errors.eof_error.cljs$lang$maxFixedArity = (1);
|
||||
|
||||
/** @this {Function} */
|
||||
cljs.tools.reader.impl.errors.eof_error.cljs$lang$applyTo = (function (seq21713){
|
||||
var G__21714 = cljs.core.first.call(null,seq21713);
|
||||
var seq21713__$1 = cljs.core.next.call(null,seq21713);
|
||||
var self__4717__auto__ = this;
|
||||
return self__4717__auto__.cljs$core$IFn$_invoke$arity$variadic(G__21714,seq21713__$1);
|
||||
});
|
||||
|
||||
cljs.tools.reader.impl.errors.throw_eof_delimited = (function cljs$tools$reader$impl$errors$throw_eof_delimited(var_args){
|
||||
var G__21719 = arguments.length;
|
||||
switch (G__21719) {
|
||||
case 4:
|
||||
return cljs.tools.reader.impl.errors.throw_eof_delimited.cljs$core$IFn$_invoke$arity$4((arguments[(0)]),(arguments[(1)]),(arguments[(2)]),(arguments[(3)]));
|
||||
|
||||
break;
|
||||
case 5:
|
||||
return cljs.tools.reader.impl.errors.throw_eof_delimited.cljs$core$IFn$_invoke$arity$5((arguments[(0)]),(arguments[(1)]),(arguments[(2)]),(arguments[(3)]),(arguments[(4)]));
|
||||
|
||||
break;
|
||||
default:
|
||||
throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
cljs.tools.reader.impl.errors.throw_eof_delimited.cljs$core$IFn$_invoke$arity$4 = (function (rdr,kind,column,line){
|
||||
return cljs.tools.reader.impl.errors.throw_eof_delimited.call(null,rdr,kind,line,column,null);
|
||||
});
|
||||
|
||||
cljs.tools.reader.impl.errors.throw_eof_delimited.cljs$core$IFn$_invoke$arity$5 = (function (rdr,kind,line,column,n){
|
||||
return cljs.tools.reader.impl.errors.eof_error.call(null,rdr,"Unexpected EOF while reading ",(cljs.core.truth_(n)?["item ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(n)," of "].join(''):null),cljs.core.name.call(null,kind),(cljs.core.truth_(line)?[", starting at line ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(line)," and column ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(column)].join(''):null),".");
|
||||
});
|
||||
|
||||
cljs.tools.reader.impl.errors.throw_eof_delimited.cljs$lang$maxFixedArity = 5;
|
||||
|
||||
cljs.tools.reader.impl.errors.throw_odd_map = (function cljs$tools$reader$impl$errors$throw_odd_map(rdr,line,col,elements){
|
||||
return cljs.tools.reader.impl.errors.reader_error.call(null,rdr,"The map literal starting with ",cljs.tools.reader.impl.inspect.inspect.call(null,cljs.core.first.call(null,elements)),(cljs.core.truth_(line)?[" on line ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(line)," column ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(col)].join(''):null)," contains ",cljs.core.count.call(null,elements)," form(s). Map literals must contain an even number of forms.");
|
||||
});
|
||||
cljs.tools.reader.impl.errors.throw_invalid_number = (function cljs$tools$reader$impl$errors$throw_invalid_number(rdr,token){
|
||||
return cljs.tools.reader.impl.errors.reader_error.call(null,rdr,"Invalid number: ",token,".");
|
||||
});
|
||||
cljs.tools.reader.impl.errors.throw_invalid_unicode_literal = (function cljs$tools$reader$impl$errors$throw_invalid_unicode_literal(rdr,token){
|
||||
throw cljs.tools.reader.impl.errors.illegal_arg_error.call(null,rdr,"Invalid unicode literal: \\",token,".");
|
||||
});
|
||||
cljs.tools.reader.impl.errors.throw_invalid_unicode_escape = (function cljs$tools$reader$impl$errors$throw_invalid_unicode_escape(rdr,ch){
|
||||
return cljs.tools.reader.impl.errors.reader_error.call(null,rdr,"Invalid unicode escape: \\u",ch,".");
|
||||
});
|
||||
cljs.tools.reader.impl.errors.throw_invalid = (function cljs$tools$reader$impl$errors$throw_invalid(rdr,kind,token){
|
||||
return cljs.tools.reader.impl.errors.reader_error.call(null,rdr,"Invalid ",cljs.core.name.call(null,kind),": ",token,".");
|
||||
});
|
||||
cljs.tools.reader.impl.errors.throw_eof_at_start = (function cljs$tools$reader$impl$errors$throw_eof_at_start(rdr,kind){
|
||||
return cljs.tools.reader.impl.errors.eof_error.call(null,rdr,"Unexpected EOF while reading start of ",cljs.core.name.call(null,kind),".");
|
||||
});
|
||||
cljs.tools.reader.impl.errors.throw_bad_char = (function cljs$tools$reader$impl$errors$throw_bad_char(rdr,kind,ch){
|
||||
return cljs.tools.reader.impl.errors.reader_error.call(null,rdr,"Invalid character: ",ch," found while reading ",cljs.core.name.call(null,kind),".");
|
||||
});
|
||||
cljs.tools.reader.impl.errors.throw_eof_at_dispatch = (function cljs$tools$reader$impl$errors$throw_eof_at_dispatch(rdr){
|
||||
return cljs.tools.reader.impl.errors.eof_error.call(null,rdr,"Unexpected EOF while reading dispatch character.");
|
||||
});
|
||||
cljs.tools.reader.impl.errors.throw_bad_dispatch = (function cljs$tools$reader$impl$errors$throw_bad_dispatch(rdr,ch){
|
||||
return cljs.tools.reader.impl.errors.reader_error.call(null,rdr,"No dispatch macro for ",ch,".");
|
||||
});
|
||||
cljs.tools.reader.impl.errors.throw_unmatch_delimiter = (function cljs$tools$reader$impl$errors$throw_unmatch_delimiter(rdr,ch){
|
||||
return cljs.tools.reader.impl.errors.reader_error.call(null,rdr,"Unmatched delimiter ",ch,".");
|
||||
});
|
||||
cljs.tools.reader.impl.errors.throw_eof_reading = (function cljs$tools$reader$impl$errors$throw_eof_reading(var_args){
|
||||
var args__4736__auto__ = [];
|
||||
var len__4730__auto___21725 = arguments.length;
|
||||
var i__4731__auto___21726 = (0);
|
||||
while(true){
|
||||
if((i__4731__auto___21726 < len__4730__auto___21725)){
|
||||
args__4736__auto__.push((arguments[i__4731__auto___21726]));
|
||||
|
||||
var G__21727 = (i__4731__auto___21726 + (1));
|
||||
i__4731__auto___21726 = G__21727;
|
||||
continue;
|
||||
} else {
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
var argseq__4737__auto__ = ((((2) < args__4736__auto__.length))?(new cljs.core.IndexedSeq(args__4736__auto__.slice((2)),(0),null)):null);
|
||||
return cljs.tools.reader.impl.errors.throw_eof_reading.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),(arguments[(1)]),argseq__4737__auto__);
|
||||
});
|
||||
|
||||
cljs.tools.reader.impl.errors.throw_eof_reading.cljs$core$IFn$_invoke$arity$variadic = (function (rdr,kind,start){
|
||||
var init = (function (){var G__21724 = kind;
|
||||
var G__21724__$1 = (((G__21724 instanceof cljs.core.Keyword))?G__21724.fqn:null);
|
||||
switch (G__21724__$1) {
|
||||
case "regex":
|
||||
return "#\"";
|
||||
|
||||
break;
|
||||
case "string":
|
||||
return "\"";
|
||||
|
||||
break;
|
||||
default:
|
||||
throw (new Error(["No matching clause: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(G__21724__$1)].join('')));
|
||||
|
||||
}
|
||||
})();
|
||||
return cljs.tools.reader.impl.errors.eof_error.call(null,rdr,"Unexpected EOF reading ",cljs.core.name.call(null,kind)," starting ",cljs.core.apply.call(null,cljs.core.str,init,start),".");
|
||||
});
|
||||
|
||||
cljs.tools.reader.impl.errors.throw_eof_reading.cljs$lang$maxFixedArity = (2);
|
||||
|
||||
/** @this {Function} */
|
||||
cljs.tools.reader.impl.errors.throw_eof_reading.cljs$lang$applyTo = (function (seq21721){
|
||||
var G__21722 = cljs.core.first.call(null,seq21721);
|
||||
var seq21721__$1 = cljs.core.next.call(null,seq21721);
|
||||
var G__21723 = cljs.core.first.call(null,seq21721__$1);
|
||||
var seq21721__$2 = cljs.core.next.call(null,seq21721__$1);
|
||||
var self__4717__auto__ = this;
|
||||
return self__4717__auto__.cljs$core$IFn$_invoke$arity$variadic(G__21722,G__21723,seq21721__$2);
|
||||
});
|
||||
|
||||
cljs.tools.reader.impl.errors.throw_no_dispatch = (function cljs$tools$reader$impl$errors$throw_no_dispatch(rdr,ch){
|
||||
return cljs.tools.reader.impl.errors.throw_bad_dispatch.call(null,rdr,ch);
|
||||
});
|
||||
cljs.tools.reader.impl.errors.throw_invalid_unicode_char = (function cljs$tools$reader$impl$errors$throw_invalid_unicode_char(rdr,token){
|
||||
return cljs.tools.reader.impl.errors.reader_error.call(null,rdr,"Invalid unicode character \\",token,".");
|
||||
});
|
||||
cljs.tools.reader.impl.errors.throw_invalid_unicode_digit_in_token = (function cljs$tools$reader$impl$errors$throw_invalid_unicode_digit_in_token(rdr,ch,token){
|
||||
return cljs.tools.reader.impl.errors.illegal_arg_error.call(null,rdr,"Invalid digit ",ch," in unicode character \\",token,".");
|
||||
});
|
||||
cljs.tools.reader.impl.errors.throw_invalid_unicode_digit = (function cljs$tools$reader$impl$errors$throw_invalid_unicode_digit(rdr,ch){
|
||||
return cljs.tools.reader.impl.errors.illegal_arg_error.call(null,rdr,"Invalid digit ",ch," in unicode character.");
|
||||
});
|
||||
cljs.tools.reader.impl.errors.throw_invalid_unicode_len = (function cljs$tools$reader$impl$errors$throw_invalid_unicode_len(rdr,actual,expected){
|
||||
return cljs.tools.reader.impl.errors.illegal_arg_error.call(null,rdr,"Invalid unicode literal. Unicode literals should be ",expected,"characters long. ","value suppled is ",actual,"characters long.");
|
||||
});
|
||||
cljs.tools.reader.impl.errors.throw_invalid_character_literal = (function cljs$tools$reader$impl$errors$throw_invalid_character_literal(rdr,token){
|
||||
return cljs.tools.reader.impl.errors.reader_error.call(null,rdr,"Invalid character literal \\u",token,".");
|
||||
});
|
||||
cljs.tools.reader.impl.errors.throw_invalid_octal_len = (function cljs$tools$reader$impl$errors$throw_invalid_octal_len(rdr,token){
|
||||
return cljs.tools.reader.impl.errors.reader_error.call(null,rdr,"Invalid octal escape sequence in a character literal:",token,". Octal escape sequences must be 3 or fewer digits.");
|
||||
});
|
||||
cljs.tools.reader.impl.errors.throw_bad_octal_number = (function cljs$tools$reader$impl$errors$throw_bad_octal_number(rdr){
|
||||
return cljs.tools.reader.impl.errors.reader_error.call(null,rdr,"Octal escape sequence must be in range [0, 377].");
|
||||
});
|
||||
cljs.tools.reader.impl.errors.throw_unsupported_character = (function cljs$tools$reader$impl$errors$throw_unsupported_character(rdr,token){
|
||||
return cljs.tools.reader.impl.errors.reader_error.call(null,rdr,"Unsupported character: ",token,".");
|
||||
});
|
||||
cljs.tools.reader.impl.errors.throw_eof_in_character = (function cljs$tools$reader$impl$errors$throw_eof_in_character(rdr){
|
||||
return cljs.tools.reader.impl.errors.eof_error.call(null,rdr,"Unexpected EOF while reading character.");
|
||||
});
|
||||
cljs.tools.reader.impl.errors.throw_bad_escape_char = (function cljs$tools$reader$impl$errors$throw_bad_escape_char(rdr,ch){
|
||||
return cljs.tools.reader.impl.errors.reader_error.call(null,rdr,"Unsupported escape character: \\",ch,".");
|
||||
});
|
||||
cljs.tools.reader.impl.errors.throw_single_colon = (function cljs$tools$reader$impl$errors$throw_single_colon(rdr){
|
||||
return cljs.tools.reader.impl.errors.reader_error.call(null,rdr,"A single colon is not a valid keyword.");
|
||||
});
|
||||
cljs.tools.reader.impl.errors.throw_bad_metadata = (function cljs$tools$reader$impl$errors$throw_bad_metadata(rdr,x){
|
||||
return cljs.tools.reader.impl.errors.reader_error.call(null,rdr,"Metadata cannot be ",cljs.tools.reader.impl.inspect.inspect.call(null,x),". Metadata must be a Symbol, Keyword, String or Map.");
|
||||
});
|
||||
cljs.tools.reader.impl.errors.throw_bad_metadata_target = (function cljs$tools$reader$impl$errors$throw_bad_metadata_target(rdr,target){
|
||||
return cljs.tools.reader.impl.errors.reader_error.call(null,rdr,"Metadata can not be applied to ",cljs.tools.reader.impl.inspect.inspect.call(null,target),". ","Metadata can only be applied to IMetas.");
|
||||
});
|
||||
cljs.tools.reader.impl.errors.throw_feature_not_keyword = (function cljs$tools$reader$impl$errors$throw_feature_not_keyword(rdr,feature){
|
||||
return cljs.tools.reader.impl.errors.reader_error.call(null,rdr,"Feature cannot be ",cljs.tools.reader.impl.inspect.inspect.call(null,feature)," Features must be keywords.");
|
||||
});
|
||||
cljs.tools.reader.impl.errors.throw_ns_map_no_map = (function cljs$tools$reader$impl$errors$throw_ns_map_no_map(rdr,ns_name){
|
||||
return cljs.tools.reader.impl.errors.reader_error.call(null,rdr,"Namespaced map with namespace ",ns_name," does not specify a map.");
|
||||
});
|
||||
cljs.tools.reader.impl.errors.throw_bad_ns = (function cljs$tools$reader$impl$errors$throw_bad_ns(rdr,ns_name){
|
||||
return cljs.tools.reader.impl.errors.reader_error.call(null,rdr,"Invalid value used as namespace in namespaced map: ",ns_name,".");
|
||||
});
|
||||
cljs.tools.reader.impl.errors.throw_bad_reader_tag = (function cljs$tools$reader$impl$errors$throw_bad_reader_tag(rdr,tag){
|
||||
return cljs.tools.reader.impl.errors.reader_error.call(null,rdr,"Invalid reader tag: ",cljs.tools.reader.impl.inspect.inspect.call(null,tag),". Reader tags must be symbols.");
|
||||
});
|
||||
cljs.tools.reader.impl.errors.throw_unknown_reader_tag = (function cljs$tools$reader$impl$errors$throw_unknown_reader_tag(rdr,tag){
|
||||
return cljs.tools.reader.impl.errors.reader_error.call(null,rdr,"No reader function for tag ",cljs.tools.reader.impl.inspect.inspect.call(null,tag),".");
|
||||
});
|
||||
cljs.tools.reader.impl.errors.duplicate_keys_error = (function cljs$tools$reader$impl$errors$duplicate_keys_error(msg,coll){
|
||||
var duplicates = (function cljs$tools$reader$impl$errors$duplicate_keys_error_$_duplicates(seq){
|
||||
var iter__4523__auto__ = (function cljs$tools$reader$impl$errors$duplicate_keys_error_$_duplicates_$_iter__21739(s__21740){
|
||||
return (new cljs.core.LazySeq(null,(function (){
|
||||
var s__21740__$1 = s__21740;
|
||||
while(true){
|
||||
var temp__5720__auto__ = cljs.core.seq.call(null,s__21740__$1);
|
||||
if(temp__5720__auto__){
|
||||
var s__21740__$2 = temp__5720__auto__;
|
||||
if(cljs.core.chunked_seq_QMARK_.call(null,s__21740__$2)){
|
||||
var c__4521__auto__ = cljs.core.chunk_first.call(null,s__21740__$2);
|
||||
var size__4522__auto__ = cljs.core.count.call(null,c__4521__auto__);
|
||||
var b__21742 = cljs.core.chunk_buffer.call(null,size__4522__auto__);
|
||||
if((function (){var i__21741 = (0);
|
||||
while(true){
|
||||
if((i__21741 < size__4522__auto__)){
|
||||
var vec__21743 = cljs.core._nth.call(null,c__4521__auto__,i__21741);
|
||||
var id = cljs.core.nth.call(null,vec__21743,(0),null);
|
||||
var freq = cljs.core.nth.call(null,vec__21743,(1),null);
|
||||
if((freq > (1))){
|
||||
cljs.core.chunk_append.call(null,b__21742,id);
|
||||
|
||||
var G__21749 = (i__21741 + (1));
|
||||
i__21741 = G__21749;
|
||||
continue;
|
||||
} else {
|
||||
var G__21750 = (i__21741 + (1));
|
||||
i__21741 = G__21750;
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
})()){
|
||||
return cljs.core.chunk_cons.call(null,cljs.core.chunk.call(null,b__21742),cljs$tools$reader$impl$errors$duplicate_keys_error_$_duplicates_$_iter__21739.call(null,cljs.core.chunk_rest.call(null,s__21740__$2)));
|
||||
} else {
|
||||
return cljs.core.chunk_cons.call(null,cljs.core.chunk.call(null,b__21742),null);
|
||||
}
|
||||
} else {
|
||||
var vec__21746 = cljs.core.first.call(null,s__21740__$2);
|
||||
var id = cljs.core.nth.call(null,vec__21746,(0),null);
|
||||
var freq = cljs.core.nth.call(null,vec__21746,(1),null);
|
||||
if((freq > (1))){
|
||||
return cljs.core.cons.call(null,id,cljs$tools$reader$impl$errors$duplicate_keys_error_$_duplicates_$_iter__21739.call(null,cljs.core.rest.call(null,s__21740__$2)));
|
||||
} else {
|
||||
var G__21751 = cljs.core.rest.call(null,s__21740__$2);
|
||||
s__21740__$1 = G__21751;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}),null,null));
|
||||
});
|
||||
return iter__4523__auto__.call(null,cljs.core.frequencies.call(null,seq));
|
||||
});
|
||||
var dups = duplicates.call(null,coll);
|
||||
return cljs.core.apply.call(null,cljs.core.str,msg,(((cljs.core.count.call(null,dups) > (1)))?"s":null),": ",cljs.core.interpose.call(null,", ",dups));
|
||||
});
|
||||
cljs.tools.reader.impl.errors.throw_dup_keys = (function cljs$tools$reader$impl$errors$throw_dup_keys(rdr,kind,ks){
|
||||
return cljs.tools.reader.impl.errors.reader_error.call(null,rdr,cljs.tools.reader.impl.errors.duplicate_keys_error.call(null,[cljs.core.str.cljs$core$IFn$_invoke$arity$1(clojure.string.capitalize.call(null,cljs.core.name.call(null,kind)))," literal contains duplicate key"].join(''),ks));
|
||||
});
|
||||
cljs.tools.reader.impl.errors.throw_eof_error = (function cljs$tools$reader$impl$errors$throw_eof_error(rdr,line){
|
||||
if(cljs.core.truth_(line)){
|
||||
return cljs.tools.reader.impl.errors.eof_error.call(null,rdr,"EOF while reading, starting at line ",line,".");
|
||||
} else {
|
||||
return cljs.tools.reader.impl.errors.eof_error.call(null,rdr,"EOF while reading.");
|
||||
}
|
||||
});
|
||||
|
||||
//# sourceMappingURL=errors.js.map
|
||||
File diff suppressed because one or more lines are too long
|
|
@ -0,0 +1,90 @@
|
|||
;; Copyright (c) Russ Olsen, Nicola Mometto, Rich Hickey & contributors.
|
||||
;; The use and distribution terms for this software are covered by the
|
||||
;; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
|
||||
;; which can be found in the file epl-v10.html at the root of this distribution.
|
||||
;; By using this software in any fashion, you are agreeing to be bound by
|
||||
;; the terms of this license.
|
||||
;; You must not remove this notice, or any other, from this software.
|
||||
|
||||
(ns cljs.tools.reader.impl.inspect)
|
||||
|
||||
(declare inspect*)
|
||||
|
||||
(defn- inspect*-col [truncate col start end]
|
||||
(let [n (count col)
|
||||
l (if truncate 0 (min 10 n))
|
||||
elements (map (partial inspect* true) (take l col))
|
||||
content (apply str (interpose " " elements))
|
||||
suffix (if (< l n) "...")]
|
||||
(str start content suffix end)))
|
||||
|
||||
(defn- dispatch-inspect
|
||||
[_ x]
|
||||
(cond
|
||||
(nil? x) :nil
|
||||
(string? x) :string
|
||||
(keyword? x) :strable
|
||||
(number? x) :strable
|
||||
(symbol? x) :strable
|
||||
(vector? x) :vector
|
||||
(list? x) :list
|
||||
(map? x) :map
|
||||
(set? x) :set
|
||||
(= x true) :strable
|
||||
(= x false) :strable
|
||||
:default (type x)))
|
||||
|
||||
(defmulti inspect* dispatch-inspect)
|
||||
|
||||
(defmethod inspect* :string [truncate ^String x]
|
||||
(let [n (if truncate 5 20)
|
||||
suffix (if (> (.-length x) n) "...\"" "\"")]
|
||||
(str
|
||||
\"
|
||||
(.substring ^String x 0 (min n (.-length x)))
|
||||
suffix)))
|
||||
|
||||
(defmethod inspect* :strable [truncate x] (str x))
|
||||
|
||||
(defmethod inspect* cljs.core/IndexedSeq [truncate x]
|
||||
"<indexed seq>")
|
||||
|
||||
(defmethod inspect* cljs.core/PersistentArrayMapSeq [truncate x]
|
||||
"<map seq>")
|
||||
|
||||
(defmethod inspect* cljs.core/NodeSeq [truncate x]
|
||||
"<map seq>")
|
||||
|
||||
(defmethod inspect* cljs.core/Cons [truncate x] "<cons>")
|
||||
|
||||
(defmethod inspect* cljs.core/LazySeq [truncate x] "<lazy seq>")
|
||||
|
||||
(defmethod inspect* :nil [_ _] "nil")
|
||||
|
||||
(defmethod inspect* :list [truncate col]
|
||||
(inspect*-col truncate col \( \)))
|
||||
|
||||
(defmethod inspect* :map [truncate m]
|
||||
(let [len (count m)
|
||||
n-shown (if truncate 0 len)
|
||||
contents (apply concat (take n-shown m))
|
||||
suffix (if (> len n-shown) "...}" \})]
|
||||
(inspect*-col truncate contents \{ suffix)))
|
||||
|
||||
(defmethod inspect* :set [truncate col]
|
||||
(inspect*-col truncate col "#{" \}))
|
||||
|
||||
(defmethod inspect* :vector [truncate col]
|
||||
(inspect*-col truncate col \[ \]))
|
||||
|
||||
(defmethod inspect* :default [truncate x]
|
||||
(pr-str (type x)))
|
||||
|
||||
(defn inspect
|
||||
"Return a string description of the value supplied.
|
||||
May be the a string version of the value itself (e.g. \"true\")
|
||||
or it may be a description (e.g. \"an instance of Foo\").
|
||||
If truncate is true then return a very terse version of
|
||||
the inspection."
|
||||
([x] (inspect* false x))
|
||||
([truncate x] (inspect* truncate x)))
|
||||
|
|
@ -0,0 +1 @@
|
|||
["^ ","~:rename-macros",["^ "],"~:renames",["^ "],"~:use-macros",["^ "],"~:excludes",["~#set",[]],"~:name","~$cljs.tools.reader.impl.inspect","~:imports",null,"~:requires",null,"~:cljs.spec/speced-vars",[],"~:uses",null,"~:defs",["^ ","~$inspect*",["^ ","^5","~$cljs.tools.reader.impl.inspect/inspect*","~:file","target/cljsbuild-compiler-1/cljs/tools/reader/impl/inspect.cljs","~:line",37,"~:column",1,"~:end-line",37,"~:end-column",19,"~:meta",["^ ","^>","/home/simon/workspace/geocsv-lite/target/cljsbuild-compiler-1/cljs/tools/reader/impl/inspect.cljs","^?",37,"^@",11,"^A",37,"^B",19],"~:tag","~$cljs.core/MultiFn"],"~$inspect*-col",["^ ","~:protocol-inline",null,"^C",["^ ","^>","/home/simon/workspace/geocsv-lite/target/cljsbuild-compiler-1/cljs/tools/reader/impl/inspect.cljs","^?",13,"^@",8,"^A",13,"^B",20,"~:private",true,"~:arglists",["~#list",["~$quote",["^J",[["~$truncate","~$col","~$start","~$end"]]]]]],"^H",true,"^5","~$cljs.tools.reader.impl.inspect/inspect*-col","^>","target/cljsbuild-compiler-1/cljs/tools/reader/impl/inspect.cljs","^B",20,"~:method-params",["^J",[["^L","^M","^N","^O"]]],"~:protocol-impl",null,"~:arglists-meta",["^J",[null,null]],"^@",1,"~:variadic?",false,"^?",13,"~:ret-tag","~$string","^A",13,"~:max-fixed-arity",4,"~:fn-var",true,"^I",["^J",["^K",["^J",[["^L","^M","^N","^O"]]]]]],"~$dispatch-inspect",["^ ","^G",null,"^C",["^ ","^>","/home/simon/workspace/geocsv-lite/target/cljsbuild-compiler-1/cljs/tools/reader/impl/inspect.cljs","^?",21,"^@",8,"^A",21,"^B",24,"^H",true,"^I",["^J",["^K",["^J",[["~$_","~$x"]]]]]],"^H",true,"^5","~$cljs.tools.reader.impl.inspect/dispatch-inspect","^>","target/cljsbuild-compiler-1/cljs/tools/reader/impl/inspect.cljs","^B",24,"^Q",["^J",[["~$_","~$x"]]],"^R",null,"^S",["^J",[null,null]],"^@",1,"^T",false,"^?",21,"^U",["^4",["~$any","~$cljs.core/Keyword","~$clj-nil"]],"^A",21,"^W",2,"^X",true,"^I",["^J",["^K",["^J",[["~$_","~$x"]]]]]],"~$inspect",["^ ","^G",null,"^C",["^ ","^>","/home/simon/workspace/geocsv-lite/target/cljsbuild-compiler-1/cljs/tools/reader/impl/inspect.cljs","^?",83,"^@",7,"^A",83,"^B",14,"^I",["^J",["^K",["^J",[["~$x"],["^L","~$x"]]]]],"~:doc","Return a string description of the value supplied.\n May be the a string version of the value itself (e.g. \"true\")\n or it may be a description (e.g. \"an instance of Foo\").\n If truncate is true then return a very terse version of\n the inspection.","~:top-fn",["^ ","^T",false,"~:fixed-arity",2,"^W",2,"^Q",["^J",[["~$x"],["^L","~$x"]]],"^I",["^J",[["~$x"],["^L","~$x"]]],"^S",["^J",[null,null]]]],"^5","~$cljs.tools.reader.impl.inspect/inspect","^>","target/cljsbuild-compiler-1/cljs/tools/reader/impl/inspect.cljs","^B",14,"^14",["^ ","^T",false,"^15",2,"^W",2,"^Q",["^J",[["~$x"],["^L","~$x"]]],"^I",["^J",[["~$x"],["^L","~$x"]]],"^S",["^J",[null,null]]],"^Q",["^J",[["~$x"],["^L","~$x"]]],"^R",null,"^15",2,"^S",["^J",[null,null]],"^@",1,"^T",false,"~:methods",[["^ ","^15",1,"^T",false,"^D","^["],["^ ","^15",2,"^T",false,"^D","^["]],"^?",83,"^A",83,"^W",2,"^X",true,"^I",["^J",[["~$x"],["^L","~$x"]]],"^13","Return a string description of the value supplied.\n May be the a string version of the value itself (e.g. \"true\")\n or it may be a description (e.g. \"an instance of Foo\").\n If truncate is true then return a very terse version of\n the inspection."]],"~:cljs.spec/registry-ref",[],"~:require-macros",null,"~:cljs.analyzer/constants",["^ ","~:seen",["^4",["~:default","~:string","~:vector","~:strable","~:list","~:nil","~:set","~:hierarchy","~:map"]],"~:order",["^1A","^1=","^1?","^1>","^1@","^1D","^1B","^1<","^1C"]],"^13",null]
|
||||
|
|
@ -0,0 +1,156 @@
|
|||
// Compiled by ClojureScript 1.10.520 {}
|
||||
goog.provide('cljs.tools.reader.impl.inspect');
|
||||
goog.require('cljs.core');
|
||||
cljs.tools.reader.impl.inspect.inspect_STAR__col = (function cljs$tools$reader$impl$inspect$inspect_STAR__col(truncate,col,start,end){
|
||||
var n = cljs.core.count.call(null,col);
|
||||
var l = (cljs.core.truth_(truncate)?(0):(function (){var x__4222__auto__ = (10);
|
||||
var y__4223__auto__ = n;
|
||||
return ((x__4222__auto__ < y__4223__auto__) ? x__4222__auto__ : y__4223__auto__);
|
||||
})());
|
||||
var elements = cljs.core.map.call(null,cljs.core.partial.call(null,cljs.tools.reader.impl.inspect.inspect_STAR_,true),cljs.core.take.call(null,l,col));
|
||||
var content = cljs.core.apply.call(null,cljs.core.str,cljs.core.interpose.call(null," ",elements));
|
||||
var suffix = (((l < n))?"...":null);
|
||||
return [cljs.core.str.cljs$core$IFn$_invoke$arity$1(start),cljs.core.str.cljs$core$IFn$_invoke$arity$1(content),suffix,cljs.core.str.cljs$core$IFn$_invoke$arity$1(end)].join('');
|
||||
});
|
||||
cljs.tools.reader.impl.inspect.dispatch_inspect = (function cljs$tools$reader$impl$inspect$dispatch_inspect(_,x){
|
||||
if((x == null)){
|
||||
return new cljs.core.Keyword(null,"nil","nil",99600501);
|
||||
} else {
|
||||
if(typeof x === 'string'){
|
||||
return new cljs.core.Keyword(null,"string","string",-1989541586);
|
||||
} else {
|
||||
if((x instanceof cljs.core.Keyword)){
|
||||
return new cljs.core.Keyword(null,"strable","strable",1877668047);
|
||||
} else {
|
||||
if(typeof x === 'number'){
|
||||
return new cljs.core.Keyword(null,"strable","strable",1877668047);
|
||||
} else {
|
||||
if((x instanceof cljs.core.Symbol)){
|
||||
return new cljs.core.Keyword(null,"strable","strable",1877668047);
|
||||
} else {
|
||||
if(cljs.core.vector_QMARK_.call(null,x)){
|
||||
return new cljs.core.Keyword(null,"vector","vector",1902966158);
|
||||
} else {
|
||||
if(cljs.core.list_QMARK_.call(null,x)){
|
||||
return new cljs.core.Keyword(null,"list","list",765357683);
|
||||
} else {
|
||||
if(cljs.core.map_QMARK_.call(null,x)){
|
||||
return new cljs.core.Keyword(null,"map","map",1371690461);
|
||||
} else {
|
||||
if(cljs.core.set_QMARK_.call(null,x)){
|
||||
return new cljs.core.Keyword(null,"set","set",304602554);
|
||||
} else {
|
||||
if(cljs.core._EQ_.call(null,x,true)){
|
||||
return new cljs.core.Keyword(null,"strable","strable",1877668047);
|
||||
} else {
|
||||
if(cljs.core._EQ_.call(null,x,false)){
|
||||
return new cljs.core.Keyword(null,"strable","strable",1877668047);
|
||||
} else {
|
||||
return cljs.core.type.call(null,x);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
if((typeof cljs !== 'undefined') && (typeof cljs.tools !== 'undefined') && (typeof cljs.tools.reader !== 'undefined') && (typeof cljs.tools.reader.impl !== 'undefined') && (typeof cljs.tools.reader.impl.inspect !== 'undefined') && (typeof cljs.tools.reader.impl.inspect.inspect_STAR_ !== 'undefined')){
|
||||
} else {
|
||||
cljs.tools.reader.impl.inspect.inspect_STAR_ = (function (){var method_table__4613__auto__ = cljs.core.atom.call(null,cljs.core.PersistentArrayMap.EMPTY);
|
||||
var prefer_table__4614__auto__ = cljs.core.atom.call(null,cljs.core.PersistentArrayMap.EMPTY);
|
||||
var method_cache__4615__auto__ = cljs.core.atom.call(null,cljs.core.PersistentArrayMap.EMPTY);
|
||||
var cached_hierarchy__4616__auto__ = cljs.core.atom.call(null,cljs.core.PersistentArrayMap.EMPTY);
|
||||
var hierarchy__4617__auto__ = cljs.core.get.call(null,cljs.core.PersistentArrayMap.EMPTY,new cljs.core.Keyword(null,"hierarchy","hierarchy",-1053470341),cljs.core.get_global_hierarchy.call(null));
|
||||
return (new cljs.core.MultiFn(cljs.core.symbol.call(null,"cljs.tools.reader.impl.inspect","inspect*"),cljs.tools.reader.impl.inspect.dispatch_inspect,new cljs.core.Keyword(null,"default","default",-1987822328),hierarchy__4617__auto__,method_table__4613__auto__,prefer_table__4614__auto__,method_cache__4615__auto__,cached_hierarchy__4616__auto__));
|
||||
})();
|
||||
}
|
||||
cljs.core._add_method.call(null,cljs.tools.reader.impl.inspect.inspect_STAR_,new cljs.core.Keyword(null,"string","string",-1989541586),(function (truncate,x){
|
||||
var n = (cljs.core.truth_(truncate)?(5):(20));
|
||||
var suffix = (((x.length > n))?"...\"":"\"");
|
||||
return ["\"",cljs.core.str.cljs$core$IFn$_invoke$arity$1(x.substring((0),(function (){var x__4222__auto__ = n;
|
||||
var y__4223__auto__ = x.length;
|
||||
return ((x__4222__auto__ < y__4223__auto__) ? x__4222__auto__ : y__4223__auto__);
|
||||
})())),suffix].join('');
|
||||
}));
|
||||
cljs.core._add_method.call(null,cljs.tools.reader.impl.inspect.inspect_STAR_,new cljs.core.Keyword(null,"strable","strable",1877668047),(function (truncate,x){
|
||||
return cljs.core.str.cljs$core$IFn$_invoke$arity$1(x);
|
||||
}));
|
||||
cljs.core._add_method.call(null,cljs.tools.reader.impl.inspect.inspect_STAR_,cljs.core.IndexedSeq,(function (truncate,x){
|
||||
return "<indexed seq>";
|
||||
}));
|
||||
cljs.core._add_method.call(null,cljs.tools.reader.impl.inspect.inspect_STAR_,cljs.core.PersistentArrayMapSeq,(function (truncate,x){
|
||||
return "<map seq>";
|
||||
}));
|
||||
cljs.core._add_method.call(null,cljs.tools.reader.impl.inspect.inspect_STAR_,cljs.core.NodeSeq,(function (truncate,x){
|
||||
return "<map seq>";
|
||||
}));
|
||||
cljs.core._add_method.call(null,cljs.tools.reader.impl.inspect.inspect_STAR_,cljs.core.Cons,(function (truncate,x){
|
||||
return "<cons>";
|
||||
}));
|
||||
cljs.core._add_method.call(null,cljs.tools.reader.impl.inspect.inspect_STAR_,cljs.core.LazySeq,(function (truncate,x){
|
||||
return "<lazy seq>";
|
||||
}));
|
||||
cljs.core._add_method.call(null,cljs.tools.reader.impl.inspect.inspect_STAR_,new cljs.core.Keyword(null,"nil","nil",99600501),(function (_,___$1){
|
||||
return "nil";
|
||||
}));
|
||||
cljs.core._add_method.call(null,cljs.tools.reader.impl.inspect.inspect_STAR_,new cljs.core.Keyword(null,"list","list",765357683),(function (truncate,col){
|
||||
return cljs.tools.reader.impl.inspect.inspect_STAR__col.call(null,truncate,col,"(",")");
|
||||
}));
|
||||
cljs.core._add_method.call(null,cljs.tools.reader.impl.inspect.inspect_STAR_,new cljs.core.Keyword(null,"map","map",1371690461),(function (truncate,m){
|
||||
var len = cljs.core.count.call(null,m);
|
||||
var n_shown = (cljs.core.truth_(truncate)?(0):len);
|
||||
var contents = cljs.core.apply.call(null,cljs.core.concat,cljs.core.take.call(null,n_shown,m));
|
||||
var suffix = (((len > n_shown))?"...}":"}");
|
||||
return cljs.tools.reader.impl.inspect.inspect_STAR__col.call(null,truncate,contents,"{",suffix);
|
||||
}));
|
||||
cljs.core._add_method.call(null,cljs.tools.reader.impl.inspect.inspect_STAR_,new cljs.core.Keyword(null,"set","set",304602554),(function (truncate,col){
|
||||
return cljs.tools.reader.impl.inspect.inspect_STAR__col.call(null,truncate,col,"#{","}");
|
||||
}));
|
||||
cljs.core._add_method.call(null,cljs.tools.reader.impl.inspect.inspect_STAR_,new cljs.core.Keyword(null,"vector","vector",1902966158),(function (truncate,col){
|
||||
return cljs.tools.reader.impl.inspect.inspect_STAR__col.call(null,truncate,col,"[","]");
|
||||
}));
|
||||
cljs.core._add_method.call(null,cljs.tools.reader.impl.inspect.inspect_STAR_,new cljs.core.Keyword(null,"default","default",-1987822328),(function (truncate,x){
|
||||
return cljs.core.pr_str.call(null,cljs.core.type.call(null,x));
|
||||
}));
|
||||
/**
|
||||
* Return a string description of the value supplied.
|
||||
* May be the a string version of the value itself (e.g. "true")
|
||||
* or it may be a description (e.g. "an instance of Foo").
|
||||
* If truncate is true then return a very terse version of
|
||||
* the inspection.
|
||||
*/
|
||||
cljs.tools.reader.impl.inspect.inspect = (function cljs$tools$reader$impl$inspect$inspect(var_args){
|
||||
var G__21693 = arguments.length;
|
||||
switch (G__21693) {
|
||||
case 1:
|
||||
return cljs.tools.reader.impl.inspect.inspect.cljs$core$IFn$_invoke$arity$1((arguments[(0)]));
|
||||
|
||||
break;
|
||||
case 2:
|
||||
return cljs.tools.reader.impl.inspect.inspect.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)]));
|
||||
|
||||
break;
|
||||
default:
|
||||
throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
cljs.tools.reader.impl.inspect.inspect.cljs$core$IFn$_invoke$arity$1 = (function (x){
|
||||
return cljs.tools.reader.impl.inspect.inspect_STAR_.call(null,false,x);
|
||||
});
|
||||
|
||||
cljs.tools.reader.impl.inspect.inspect.cljs$core$IFn$_invoke$arity$2 = (function (truncate,x){
|
||||
return cljs.tools.reader.impl.inspect.inspect_STAR_.call(null,truncate,x);
|
||||
});
|
||||
|
||||
cljs.tools.reader.impl.inspect.inspect.cljs$lang$maxFixedArity = 2;
|
||||
|
||||
|
||||
//# sourceMappingURL=inspect.js.map
|
||||
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"\/home\/simon\/workspace\/geocsv-lite\/target\/cljsbuild-compiler-1\/cljs\/tools\/reader\/impl\/inspect.js","sources":["inspect.cljs"],"lineCount":156,"mappings":";AAQA;;AAEA,AAAA,AAEA,mDAAA,nDAAOA,8GAAcC,SAASC,IAAIC,MAAMC;AAAxC,AACE,IAAMC,IAAE,AAACC,0BAAMJ;IACTK,IAAE,4BAAA,VAAIN,cAAW,iBAAAO,kBAAA;IAAAC,kBAAQJ;AAAR,AAAA,SAAAG,kBAAAC,mBAAAD,kBAAAC;;IACjBC,WAAS,AAACC,wBAAI,yEAAA,zEAACC,4BAAQC,mDAAe,AAACC,yBAAKP,EAAEL;IAC9Ca,UAAQ,AAACC,0BAAMC,cAAI,8BAAA,9BAACC,kCAAcR;IAClCS,SAAO,WAAA,MAAA,fAAI,CAAGZ,IAAEF;AAJtB,AAKE,oDAAKF,mDAAMY,SAAQI,mDAAOf;;AAE9B,kDAAA,lDAAOgB,4GACJC,EAAEC;AADL,AAEE,GACC,MAAA,LAAMA;AADP;;AAAA,GAEC,OAASA;AAFV;;AAAA,GAGC,cAAAC,bAAUD;AAHX;;AAAA,GAIC,OAASA;AAJV;;AAAA,GAKC,cAAAE,bAASF;AALV;;AAAA,GAMC,AAACG,kCAAQH;AANV;;AAAA,GAOC,AAACI,gCAAMJ;AAPR;;AAAA,GAQC,AAACK,+BAAKL;AARP;;AAAA,GASC,AAACM,+BAAKN;AATP;;AAAA,GAUC,2BAAA,3BAACO,yBAAEP;AAVJ;;AAAA,GAWC,2BAAA,3BAACO,yBAAEP;AAXJ;;AAAA,AAYU,OAACQ,yBAAKR;;;;;;;;;;;;;;AAElB,GAAA,QAAAS,iCAAAC,uCAAAC,8CAAAC,mDAAAC,2DAAAC;AAAA;AAAA,AAAA,+CAAA,iBAAAC,6BAAA,AAAAC,yBAAA,tHAAUzB;IAAV0B,6BAAA,AAAAD,yBAAA;IAAAE,6BAAA,AAAAF,yBAAA;IAAAG,iCAAA,AAAAH,yBAAA;IAAAI,0BAAA,AAAAC,wBAAA,mCAAA,gEAAA,AAAA;AAAA,AAAA,YAAAC,kBAAA,AAAAC,2BAAA,iCAAA,4DAAA,4DAAAH,wBAAAL,2BAAAE,2BAAAC,2BAAAC,rNAAmBrB;;;AAEnB,AAAA0B,gCAAAjC,6CAAA,0DAAA,WAA6BZ,SAAiBqB;AAA9C,AACE,IAAMjB,IAAE,4BAAA,IAAA,dAAIJ;IACNkB,SAAO,kBAAA,QAAA,xBAAI,CAAG,AAAUG,WAAGjB;AADjC,AAEE,QAAA,iDAEE,YAAA,ZAAoBiB,gBAAI,iBAAAd,kBAAKH;IAALI,kBAAO,AAAUa;AAAjB,AAAA,SAAAd,kBAAAC,mBAAAD,kBAAAC;OACxBU;;AAEN,AAAA2B,gCAAAjC,6CAAA,2DAAA,WAA8BZ,SAASqB;AAAvC,AAA0C,mDAAKA;;AAE\/C,AAAAwB,gCAAAjC,kEAAA,rBAAoBkC,gCAAsB9C,SAASqB;AAAnD,AAAA;;AAGA,AAAAwB,gCAAAjC,6EAAA,hCAAoBmC,2CAAiC\/C,SAASqB;AAA9D,AAAA;;AAGA,AAAAwB,gCAAAjC,+DAAA,lBAAoBoC,6BAAmBhD,SAASqB;AAAhD,AAAA;;AAGA,AAAAwB,gCAAAjC,4DAAA,fAAoBqC,0BAAgBjD,SAASqB;AAA7C,AAAA;;AAEA,AAAAwB,gCAAAjC,+DAAA,lBAAoBsC,6BAAmBlD,SAASqB;AAAhD,AAAA;;AAEA,AAAAwB,gCAAAjC,6CAAA,iDAAA,WAA0BQ,EAAEA;AAA5B,AAAA;;AAEA,AAAAyB,gCAAAjC,6CAAA,oDAAA,WAA2BZ,SAASC;AAApC,AACE,+EAAA,IAAA,5EAACF,2DAAaC,SAASC;;AAEzB,AAAA4C,gCAAAjC,6CAAA,mDAAA,WAA0BZ,SAASmD;AAAnC,AACE,IAAMC,MAAI,AAAC\/C,0BAAM8C;IACXE,UAAQ,4BAAA,VAAIrD,cAAWoD;IACvBE,WAAS,AAACvC,0BAAMwC,iBAAO,AAAC1C,yBAAKwC,QAAQF;IACrCjC,SAAO,mBAAA,OAAA,xBAAI,CAAGkC,MAAIC;AAHxB,AAIE,oFAAA,7EAACtD,2DAAaC,SAASsD,aAAYpC;;AAEvC,AAAA2B,gCAAAjC,6CAAA,kDAAA,WAA0BZ,SAASC;AAAnC,AACE,+EAAA,KAAA,7EAACF,2DAAaC,SAASC;;AAEzB,AAAA4C,gCAAAjC,6CAAA,yDAAA,WAA6BZ,SAASC;AAAtC,AACE,+EAAA,IAAA,5EAACF,2DAAaC,SAASC;;AAEzB,AAAA4C,gCAAAjC,6CAAA,4DAAA,WAA8BZ,SAASqB;AAAvC,AACE,OAACmC,2BAAO,AAAC3B,yBAAKR;;AAEhB,AAAA;;;;;;;yCAAA,iDAAAoC,1FAAME;AAAN,AAAA,IAAAD,WAAA,AAAA;AAAA,AAAA,QAAAA;KAAA;AAAA,OAAAC,qEAAA,CAAA,UAAA;;;KAAA;AAAA,OAAAA,qEAAA,CAAA,UAAA,MAAA,CAAA,UAAA;;;;AAAA,MAAA,KAAAC,MAAA,CAAA,8DAAA,AAAA;;;;;AAAA,AAAA,uEAAA,vEAAMD,kFAMFtC;AANJ,AAMO,8DAAA,vDAACT,6DAAeS;;;AANvB,AAAA,uEAAA,vEAAMsC,kFAOF3D,SAASqB;AAPb,AAOgB,OAACT,uDAASZ,SAASqB;;;AAPnC,AAAA,iEAAA,jEAAMsC;;AAAN","names":["cljs.tools.reader.impl.inspect\/inspect*-col","truncate","col","start","end","n","cljs.core\/count","l","x__4222__auto__","y__4223__auto__","elements","cljs.core\/map","cljs.core\/partial","cljs.tools.reader.impl.inspect\/inspect*","cljs.core\/take","content","cljs.core\/apply","cljs.core\/str","cljs.core\/interpose","suffix","cljs.tools.reader.impl.inspect\/dispatch-inspect","_","x","cljs.core\/Keyword","cljs.core\/Symbol","cljs.core\/vector?","cljs.core\/list?","cljs.core\/map?","cljs.core\/set?","cljs.core\/=","cljs.core\/type","js\/cljs","js\/cljs.tools","js\/cljs.tools.reader","js\/cljs.tools.reader.impl","js\/cljs.tools.reader.impl.inspect","js\/cljs.tools.reader.impl.inspect.inspect*","method-table__4613__auto__","cljs.core\/atom","prefer-table__4614__auto__","method-cache__4615__auto__","cached-hierarchy__4616__auto__","hierarchy__4617__auto__","cljs.core\/get","cljs.core\/MultiFn","cljs.core\/symbol","cljs.core\/-add-method","cljs.core\/IndexedSeq","cljs.core\/PersistentArrayMapSeq","cljs.core\/NodeSeq","cljs.core\/Cons","cljs.core\/LazySeq","m","len","n-shown","contents","cljs.core\/concat","cljs.core\/pr-str","var_args","G__21693","cljs.tools.reader.impl.inspect\/inspect","js\/Error"]}
|
||||
|
|
@ -0,0 +1,103 @@
|
|||
;; Copyright (c) Nicola Mometto, Rich Hickey & contributors.
|
||||
;; The use and distribution terms for this software are covered by the
|
||||
;; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
|
||||
;; which can be found in the file epl-v10.html at the root of this distribution.
|
||||
;; By using this software in any fashion, you are agreeing to be bound by
|
||||
;; the terms of this license.
|
||||
;; You must not remove this notice, or any other, from this software.
|
||||
|
||||
(ns cljs.tools.reader.impl.utils
|
||||
(:refer-clojure :exclude [char])
|
||||
(:require
|
||||
[clojure.string :as string]
|
||||
[goog.string :as gstring]))
|
||||
|
||||
(defn char [x]
|
||||
(when-not (nil? x)
|
||||
(cljs.core/char x)))
|
||||
|
||||
(defn ^boolean ex-info? [ex]
|
||||
(instance? cljs.core.ExceptionInfo ex))
|
||||
|
||||
(defrecord ReaderConditional [splicing? form])
|
||||
|
||||
(defn ^boolean reader-conditional?
|
||||
"Return true if the value is the data representation of a reader conditional"
|
||||
[value]
|
||||
(instance? ReaderConditional value))
|
||||
|
||||
(defn reader-conditional
|
||||
"Construct a data representation of a reader conditional.
|
||||
If true, splicing? indicates read-cond-splicing."
|
||||
[form splicing?]
|
||||
(ReaderConditional. splicing? form))
|
||||
|
||||
(extend-protocol IPrintWithWriter
|
||||
ReaderConditional
|
||||
(-pr-writer [coll writer opts]
|
||||
(-write writer (str "#?" (when (:splicing? coll) "@")))
|
||||
(pr-writer (:form coll) writer opts)))
|
||||
|
||||
(def ws-rx #"[\s]")
|
||||
|
||||
(defn ^boolean whitespace?
|
||||
"Checks whether a given character is whitespace"
|
||||
[ch]
|
||||
(when-not (nil? ch)
|
||||
(if (identical? ch \,)
|
||||
true
|
||||
(.test ws-rx ch))))
|
||||
|
||||
(defn ^boolean numeric?
|
||||
"Checks whether a given character is numeric"
|
||||
[ch]
|
||||
(when-not (nil? ch)
|
||||
(gstring/isNumeric ch)))
|
||||
|
||||
(defn ^boolean newline?
|
||||
"Checks whether the character is a newline"
|
||||
[c]
|
||||
(or (identical? \newline c)
|
||||
(identical? "\n" c)
|
||||
(nil? c)))
|
||||
|
||||
(defn desugar-meta
|
||||
"Resolves syntactical sugar in metadata" ;; could be combined with some other desugar?
|
||||
[f]
|
||||
(cond
|
||||
(keyword? f) {f true}
|
||||
(symbol? f) {:tag f}
|
||||
(string? f) {:tag f}
|
||||
:else f))
|
||||
|
||||
(def last-id (atom 0))
|
||||
|
||||
(defn next-id
|
||||
[]
|
||||
(swap! last-id inc))
|
||||
|
||||
(defn namespace-keys [ns keys]
|
||||
(for [key keys]
|
||||
(if (or (symbol? key)
|
||||
(keyword? key))
|
||||
(let [[key-ns key-name] ((juxt namespace name) key)
|
||||
->key (if (symbol? key) symbol keyword)]
|
||||
(cond
|
||||
(nil? key-ns)
|
||||
(->key ns key-name)
|
||||
|
||||
(= "_" key-ns)
|
||||
(->key key-name)
|
||||
|
||||
:else
|
||||
key))
|
||||
key)))
|
||||
|
||||
(defn second' [[a b]]
|
||||
(when-not a b))
|
||||
|
||||
(defn char-code [ch base]
|
||||
(let [code (js/parseInt ch base)]
|
||||
(if (js/isNaN code)
|
||||
-1
|
||||
code)))
|
||||
File diff suppressed because one or more lines are too long
|
|
@ -0,0 +1,391 @@
|
|||
// Compiled by ClojureScript 1.10.520 {}
|
||||
goog.provide('cljs.tools.reader.impl.utils');
|
||||
goog.require('cljs.core');
|
||||
goog.require('clojure.string');
|
||||
goog.require('goog.string');
|
||||
cljs.tools.reader.impl.utils.char$ = (function cljs$tools$reader$impl$utils$char(x){
|
||||
if((x == null)){
|
||||
return null;
|
||||
} else {
|
||||
return cljs.core.char$.call(null,x);
|
||||
}
|
||||
});
|
||||
cljs.tools.reader.impl.utils.ex_info_QMARK_ = (function cljs$tools$reader$impl$utils$ex_info_QMARK_(ex){
|
||||
return (ex instanceof cljs.core.ExceptionInfo);
|
||||
});
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @implements {cljs.core.IRecord}
|
||||
* @implements {cljs.core.IKVReduce}
|
||||
* @implements {cljs.core.IEquiv}
|
||||
* @implements {cljs.core.IHash}
|
||||
* @implements {cljs.core.ICollection}
|
||||
* @implements {cljs.core.ICounted}
|
||||
* @implements {cljs.core.ISeqable}
|
||||
* @implements {cljs.core.IMeta}
|
||||
* @implements {cljs.core.ICloneable}
|
||||
* @implements {cljs.core.IPrintWithWriter}
|
||||
* @implements {cljs.core.IIterable}
|
||||
* @implements {cljs.core.IWithMeta}
|
||||
* @implements {cljs.core.IAssociative}
|
||||
* @implements {cljs.core.IMap}
|
||||
* @implements {cljs.core.ILookup}
|
||||
*/
|
||||
cljs.tools.reader.impl.utils.ReaderConditional = (function (splicing_QMARK_,form,__meta,__extmap,__hash){
|
||||
this.splicing_QMARK_ = splicing_QMARK_;
|
||||
this.form = form;
|
||||
this.__meta = __meta;
|
||||
this.__extmap = __extmap;
|
||||
this.__hash = __hash;
|
||||
this.cljs$lang$protocol_mask$partition0$ = 2230716170;
|
||||
this.cljs$lang$protocol_mask$partition1$ = 139264;
|
||||
});
|
||||
cljs.tools.reader.impl.utils.ReaderConditional.prototype.cljs$core$ILookup$_lookup$arity$2 = (function (this__4385__auto__,k__4386__auto__){
|
||||
var self__ = this;
|
||||
var this__4385__auto____$1 = this;
|
||||
return this__4385__auto____$1.cljs$core$ILookup$_lookup$arity$3(null,k__4386__auto__,null);
|
||||
});
|
||||
|
||||
cljs.tools.reader.impl.utils.ReaderConditional.prototype.cljs$core$ILookup$_lookup$arity$3 = (function (this__4387__auto__,k21646,else__4388__auto__){
|
||||
var self__ = this;
|
||||
var this__4387__auto____$1 = this;
|
||||
var G__21650 = k21646;
|
||||
var G__21650__$1 = (((G__21650 instanceof cljs.core.Keyword))?G__21650.fqn:null);
|
||||
switch (G__21650__$1) {
|
||||
case "splicing?":
|
||||
return self__.splicing_QMARK_;
|
||||
|
||||
break;
|
||||
case "form":
|
||||
return self__.form;
|
||||
|
||||
break;
|
||||
default:
|
||||
return cljs.core.get.call(null,self__.__extmap,k21646,else__4388__auto__);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
cljs.tools.reader.impl.utils.ReaderConditional.prototype.cljs$core$IKVReduce$_kv_reduce$arity$3 = (function (this__4404__auto__,f__4405__auto__,init__4406__auto__){
|
||||
var self__ = this;
|
||||
var this__4404__auto____$1 = this;
|
||||
return cljs.core.reduce.call(null,((function (this__4404__auto____$1){
|
||||
return (function (ret__4407__auto__,p__21651){
|
||||
var vec__21652 = p__21651;
|
||||
var k__4408__auto__ = cljs.core.nth.call(null,vec__21652,(0),null);
|
||||
var v__4409__auto__ = cljs.core.nth.call(null,vec__21652,(1),null);
|
||||
return f__4405__auto__.call(null,ret__4407__auto__,k__4408__auto__,v__4409__auto__);
|
||||
});})(this__4404__auto____$1))
|
||||
,init__4406__auto__,this__4404__auto____$1);
|
||||
});
|
||||
|
||||
cljs.tools.reader.impl.utils.ReaderConditional.prototype.cljs$core$IPrintWithWriter$_pr_writer$arity$3 = (function (this__4399__auto__,writer__4400__auto__,opts__4401__auto__){
|
||||
var self__ = this;
|
||||
var this__4399__auto____$1 = this;
|
||||
var pr_pair__4402__auto__ = ((function (this__4399__auto____$1){
|
||||
return (function (keyval__4403__auto__){
|
||||
return cljs.core.pr_sequential_writer.call(null,writer__4400__auto__,cljs.core.pr_writer,""," ","",opts__4401__auto__,keyval__4403__auto__);
|
||||
});})(this__4399__auto____$1))
|
||||
;
|
||||
return cljs.core.pr_sequential_writer.call(null,writer__4400__auto__,pr_pair__4402__auto__,"#cljs.tools.reader.impl.utils.ReaderConditional{",", ","}",opts__4401__auto__,cljs.core.concat.call(null,new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [(new cljs.core.PersistentVector(null,2,(5),cljs.core.PersistentVector.EMPTY_NODE,[new cljs.core.Keyword(null,"splicing?","splicing?",-428596366),self__.splicing_QMARK_],null)),(new cljs.core.PersistentVector(null,2,(5),cljs.core.PersistentVector.EMPTY_NODE,[new cljs.core.Keyword(null,"form","form",-1624062471),self__.form],null))], null),self__.__extmap));
|
||||
});
|
||||
|
||||
cljs.tools.reader.impl.utils.ReaderConditional.prototype.cljs$core$IIterable$_iterator$arity$1 = (function (G__21645){
|
||||
var self__ = this;
|
||||
var G__21645__$1 = this;
|
||||
return (new cljs.core.RecordIter((0),G__21645__$1,2,new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"splicing?","splicing?",-428596366),new cljs.core.Keyword(null,"form","form",-1624062471)], null),(cljs.core.truth_(self__.__extmap)?cljs.core._iterator.call(null,self__.__extmap):cljs.core.nil_iter.call(null))));
|
||||
});
|
||||
|
||||
cljs.tools.reader.impl.utils.ReaderConditional.prototype.cljs$core$IMeta$_meta$arity$1 = (function (this__4383__auto__){
|
||||
var self__ = this;
|
||||
var this__4383__auto____$1 = this;
|
||||
return self__.__meta;
|
||||
});
|
||||
|
||||
cljs.tools.reader.impl.utils.ReaderConditional.prototype.cljs$core$ICloneable$_clone$arity$1 = (function (this__4380__auto__){
|
||||
var self__ = this;
|
||||
var this__4380__auto____$1 = this;
|
||||
return (new cljs.tools.reader.impl.utils.ReaderConditional(self__.splicing_QMARK_,self__.form,self__.__meta,self__.__extmap,self__.__hash));
|
||||
});
|
||||
|
||||
cljs.tools.reader.impl.utils.ReaderConditional.prototype.cljs$core$ICounted$_count$arity$1 = (function (this__4389__auto__){
|
||||
var self__ = this;
|
||||
var this__4389__auto____$1 = this;
|
||||
return (2 + cljs.core.count.call(null,self__.__extmap));
|
||||
});
|
||||
|
||||
cljs.tools.reader.impl.utils.ReaderConditional.prototype.cljs$core$IHash$_hash$arity$1 = (function (this__4381__auto__){
|
||||
var self__ = this;
|
||||
var this__4381__auto____$1 = this;
|
||||
var h__4243__auto__ = self__.__hash;
|
||||
if((!((h__4243__auto__ == null)))){
|
||||
return h__4243__auto__;
|
||||
} else {
|
||||
var h__4243__auto____$1 = ((function (h__4243__auto__,this__4381__auto____$1){
|
||||
return (function (coll__4382__auto__){
|
||||
return (-209062840 ^ cljs.core.hash_unordered_coll.call(null,coll__4382__auto__));
|
||||
});})(h__4243__auto__,this__4381__auto____$1))
|
||||
.call(null,this__4381__auto____$1);
|
||||
self__.__hash = h__4243__auto____$1;
|
||||
|
||||
return h__4243__auto____$1;
|
||||
}
|
||||
});
|
||||
|
||||
cljs.tools.reader.impl.utils.ReaderConditional.prototype.cljs$core$IEquiv$_equiv$arity$2 = (function (this21647,other21648){
|
||||
var self__ = this;
|
||||
var this21647__$1 = this;
|
||||
return (((!((other21648 == null)))) && ((this21647__$1.constructor === other21648.constructor)) && (cljs.core._EQ_.call(null,this21647__$1.splicing_QMARK_,other21648.splicing_QMARK_)) && (cljs.core._EQ_.call(null,this21647__$1.form,other21648.form)) && (cljs.core._EQ_.call(null,this21647__$1.__extmap,other21648.__extmap)));
|
||||
});
|
||||
|
||||
cljs.tools.reader.impl.utils.ReaderConditional.prototype.cljs$core$IMap$_dissoc$arity$2 = (function (this__4394__auto__,k__4395__auto__){
|
||||
var self__ = this;
|
||||
var this__4394__auto____$1 = this;
|
||||
if(cljs.core.contains_QMARK_.call(null,new cljs.core.PersistentHashSet(null, new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"splicing?","splicing?",-428596366),null,new cljs.core.Keyword(null,"form","form",-1624062471),null], null), null),k__4395__auto__)){
|
||||
return cljs.core.dissoc.call(null,cljs.core._with_meta.call(null,cljs.core.into.call(null,cljs.core.PersistentArrayMap.EMPTY,this__4394__auto____$1),self__.__meta),k__4395__auto__);
|
||||
} else {
|
||||
return (new cljs.tools.reader.impl.utils.ReaderConditional(self__.splicing_QMARK_,self__.form,self__.__meta,cljs.core.not_empty.call(null,cljs.core.dissoc.call(null,self__.__extmap,k__4395__auto__)),null));
|
||||
}
|
||||
});
|
||||
|
||||
cljs.tools.reader.impl.utils.ReaderConditional.prototype.cljs$core$IAssociative$_assoc$arity$3 = (function (this__4392__auto__,k__4393__auto__,G__21645){
|
||||
var self__ = this;
|
||||
var this__4392__auto____$1 = this;
|
||||
var pred__21655 = cljs.core.keyword_identical_QMARK_;
|
||||
var expr__21656 = k__4393__auto__;
|
||||
if(cljs.core.truth_(pred__21655.call(null,new cljs.core.Keyword(null,"splicing?","splicing?",-428596366),expr__21656))){
|
||||
return (new cljs.tools.reader.impl.utils.ReaderConditional(G__21645,self__.form,self__.__meta,self__.__extmap,null));
|
||||
} else {
|
||||
if(cljs.core.truth_(pred__21655.call(null,new cljs.core.Keyword(null,"form","form",-1624062471),expr__21656))){
|
||||
return (new cljs.tools.reader.impl.utils.ReaderConditional(self__.splicing_QMARK_,G__21645,self__.__meta,self__.__extmap,null));
|
||||
} else {
|
||||
return (new cljs.tools.reader.impl.utils.ReaderConditional(self__.splicing_QMARK_,self__.form,self__.__meta,cljs.core.assoc.call(null,self__.__extmap,k__4393__auto__,G__21645),null));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
cljs.tools.reader.impl.utils.ReaderConditional.prototype.cljs$core$ISeqable$_seq$arity$1 = (function (this__4397__auto__){
|
||||
var self__ = this;
|
||||
var this__4397__auto____$1 = this;
|
||||
return cljs.core.seq.call(null,cljs.core.concat.call(null,new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [(new cljs.core.MapEntry(new cljs.core.Keyword(null,"splicing?","splicing?",-428596366),self__.splicing_QMARK_,null)),(new cljs.core.MapEntry(new cljs.core.Keyword(null,"form","form",-1624062471),self__.form,null))], null),self__.__extmap));
|
||||
});
|
||||
|
||||
cljs.tools.reader.impl.utils.ReaderConditional.prototype.cljs$core$IWithMeta$_with_meta$arity$2 = (function (this__4384__auto__,G__21645){
|
||||
var self__ = this;
|
||||
var this__4384__auto____$1 = this;
|
||||
return (new cljs.tools.reader.impl.utils.ReaderConditional(self__.splicing_QMARK_,self__.form,G__21645,self__.__extmap,self__.__hash));
|
||||
});
|
||||
|
||||
cljs.tools.reader.impl.utils.ReaderConditional.prototype.cljs$core$ICollection$_conj$arity$2 = (function (this__4390__auto__,entry__4391__auto__){
|
||||
var self__ = this;
|
||||
var this__4390__auto____$1 = this;
|
||||
if(cljs.core.vector_QMARK_.call(null,entry__4391__auto__)){
|
||||
return this__4390__auto____$1.cljs$core$IAssociative$_assoc$arity$3(null,cljs.core._nth.call(null,entry__4391__auto__,(0)),cljs.core._nth.call(null,entry__4391__auto__,(1)));
|
||||
} else {
|
||||
return cljs.core.reduce.call(null,cljs.core._conj,this__4390__auto____$1,entry__4391__auto__);
|
||||
}
|
||||
});
|
||||
|
||||
cljs.tools.reader.impl.utils.ReaderConditional.getBasis = (function (){
|
||||
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Symbol(null,"splicing?","splicing?",1211935161,null),new cljs.core.Symbol(null,"form","form",16469056,null)], null);
|
||||
});
|
||||
|
||||
cljs.tools.reader.impl.utils.ReaderConditional.cljs$lang$type = true;
|
||||
|
||||
cljs.tools.reader.impl.utils.ReaderConditional.cljs$lang$ctorPrSeq = (function (this__4428__auto__){
|
||||
return (new cljs.core.List(null,"cljs.tools.reader.impl.utils/ReaderConditional",null,(1),null));
|
||||
});
|
||||
|
||||
cljs.tools.reader.impl.utils.ReaderConditional.cljs$lang$ctorPrWriter = (function (this__4428__auto__,writer__4429__auto__){
|
||||
return cljs.core._write.call(null,writer__4429__auto__,"cljs.tools.reader.impl.utils/ReaderConditional");
|
||||
});
|
||||
|
||||
/**
|
||||
* Positional factory function for cljs.tools.reader.impl.utils/ReaderConditional.
|
||||
*/
|
||||
cljs.tools.reader.impl.utils.__GT_ReaderConditional = (function cljs$tools$reader$impl$utils$__GT_ReaderConditional(splicing_QMARK_,form){
|
||||
return (new cljs.tools.reader.impl.utils.ReaderConditional(splicing_QMARK_,form,null,null,null));
|
||||
});
|
||||
|
||||
/**
|
||||
* Factory function for cljs.tools.reader.impl.utils/ReaderConditional, taking a map of keywords to field values.
|
||||
*/
|
||||
cljs.tools.reader.impl.utils.map__GT_ReaderConditional = (function cljs$tools$reader$impl$utils$map__GT_ReaderConditional(G__21649){
|
||||
var extmap__4424__auto__ = (function (){var G__21658 = cljs.core.dissoc.call(null,G__21649,new cljs.core.Keyword(null,"splicing?","splicing?",-428596366),new cljs.core.Keyword(null,"form","form",-1624062471));
|
||||
if(cljs.core.record_QMARK_.call(null,G__21649)){
|
||||
return cljs.core.into.call(null,cljs.core.PersistentArrayMap.EMPTY,G__21658);
|
||||
} else {
|
||||
return G__21658;
|
||||
}
|
||||
})();
|
||||
return (new cljs.tools.reader.impl.utils.ReaderConditional(new cljs.core.Keyword(null,"splicing?","splicing?",-428596366).cljs$core$IFn$_invoke$arity$1(G__21649),new cljs.core.Keyword(null,"form","form",-1624062471).cljs$core$IFn$_invoke$arity$1(G__21649),null,cljs.core.not_empty.call(null,extmap__4424__auto__),null));
|
||||
});
|
||||
|
||||
/**
|
||||
* Return true if the value is the data representation of a reader conditional
|
||||
*/
|
||||
cljs.tools.reader.impl.utils.reader_conditional_QMARK_ = (function cljs$tools$reader$impl$utils$reader_conditional_QMARK_(value){
|
||||
return (value instanceof cljs.tools.reader.impl.utils.ReaderConditional);
|
||||
});
|
||||
/**
|
||||
* Construct a data representation of a reader conditional.
|
||||
* If true, splicing? indicates read-cond-splicing.
|
||||
*/
|
||||
cljs.tools.reader.impl.utils.reader_conditional = (function cljs$tools$reader$impl$utils$reader_conditional(form,splicing_QMARK_){
|
||||
return (new cljs.tools.reader.impl.utils.ReaderConditional(splicing_QMARK_,form,null,null,null));
|
||||
});
|
||||
cljs.tools.reader.impl.utils.ReaderConditional.prototype.cljs$core$IPrintWithWriter$ = cljs.core.PROTOCOL_SENTINEL;
|
||||
|
||||
cljs.tools.reader.impl.utils.ReaderConditional.prototype.cljs$core$IPrintWithWriter$_pr_writer$arity$3 = (function (coll,writer,opts){
|
||||
var coll__$1 = this;
|
||||
cljs.core._write.call(null,writer,["#?",(cljs.core.truth_(new cljs.core.Keyword(null,"splicing?","splicing?",-428596366).cljs$core$IFn$_invoke$arity$1(coll__$1))?"@":null)].join(''));
|
||||
|
||||
return cljs.core.pr_writer.call(null,new cljs.core.Keyword(null,"form","form",-1624062471).cljs$core$IFn$_invoke$arity$1(coll__$1),writer,opts);
|
||||
});
|
||||
cljs.tools.reader.impl.utils.ws_rx = /[\s]/;
|
||||
/**
|
||||
* Checks whether a given character is whitespace
|
||||
*/
|
||||
cljs.tools.reader.impl.utils.whitespace_QMARK_ = (function cljs$tools$reader$impl$utils$whitespace_QMARK_(ch){
|
||||
if((ch == null)){
|
||||
return null;
|
||||
} else {
|
||||
if((ch === ",")){
|
||||
return true;
|
||||
} else {
|
||||
return cljs.tools.reader.impl.utils.ws_rx.test(ch);
|
||||
}
|
||||
}
|
||||
});
|
||||
/**
|
||||
* Checks whether a given character is numeric
|
||||
*/
|
||||
cljs.tools.reader.impl.utils.numeric_QMARK_ = (function cljs$tools$reader$impl$utils$numeric_QMARK_(ch){
|
||||
if((ch == null)){
|
||||
return null;
|
||||
} else {
|
||||
return goog.string.isNumeric(ch);
|
||||
}
|
||||
});
|
||||
/**
|
||||
* Checks whether the character is a newline
|
||||
*/
|
||||
cljs.tools.reader.impl.utils.newline_QMARK_ = (function cljs$tools$reader$impl$utils$newline_QMARK_(c){
|
||||
return ((("\n" === c)) || (("\n" === c)) || ((c == null)));
|
||||
});
|
||||
/**
|
||||
* Resolves syntactical sugar in metadata
|
||||
*/
|
||||
cljs.tools.reader.impl.utils.desugar_meta = (function cljs$tools$reader$impl$utils$desugar_meta(f){
|
||||
if((f instanceof cljs.core.Keyword)){
|
||||
return cljs.core.PersistentArrayMap.createAsIfByAssoc([f,true]);
|
||||
} else {
|
||||
if((f instanceof cljs.core.Symbol)){
|
||||
return new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"tag","tag",-1290361223),f], null);
|
||||
} else {
|
||||
if(typeof f === 'string'){
|
||||
return new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"tag","tag",-1290361223),f], null);
|
||||
} else {
|
||||
return f;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
cljs.tools.reader.impl.utils.last_id = cljs.core.atom.call(null,(0));
|
||||
cljs.tools.reader.impl.utils.next_id = (function cljs$tools$reader$impl$utils$next_id(){
|
||||
return cljs.core.swap_BANG_.call(null,cljs.tools.reader.impl.utils.last_id,cljs.core.inc);
|
||||
});
|
||||
cljs.tools.reader.impl.utils.namespace_keys = (function cljs$tools$reader$impl$utils$namespace_keys(ns,keys){
|
||||
var iter__4523__auto__ = (function cljs$tools$reader$impl$utils$namespace_keys_$_iter__21660(s__21661){
|
||||
return (new cljs.core.LazySeq(null,(function (){
|
||||
var s__21661__$1 = s__21661;
|
||||
while(true){
|
||||
var temp__5720__auto__ = cljs.core.seq.call(null,s__21661__$1);
|
||||
if(temp__5720__auto__){
|
||||
var s__21661__$2 = temp__5720__auto__;
|
||||
if(cljs.core.chunked_seq_QMARK_.call(null,s__21661__$2)){
|
||||
var c__4521__auto__ = cljs.core.chunk_first.call(null,s__21661__$2);
|
||||
var size__4522__auto__ = cljs.core.count.call(null,c__4521__auto__);
|
||||
var b__21663 = cljs.core.chunk_buffer.call(null,size__4522__auto__);
|
||||
if((function (){var i__21662 = (0);
|
||||
while(true){
|
||||
if((i__21662 < size__4522__auto__)){
|
||||
var key = cljs.core._nth.call(null,c__4521__auto__,i__21662);
|
||||
cljs.core.chunk_append.call(null,b__21663,(((((key instanceof cljs.core.Symbol)) || ((key instanceof cljs.core.Keyword))))?(function (){var vec__21664 = cljs.core.juxt.call(null,cljs.core.namespace,cljs.core.name).call(null,key);
|
||||
var key_ns = cljs.core.nth.call(null,vec__21664,(0),null);
|
||||
var key_name = cljs.core.nth.call(null,vec__21664,(1),null);
|
||||
var __GT_key = (((key instanceof cljs.core.Symbol))?cljs.core.symbol:cljs.core.keyword);
|
||||
if((key_ns == null)){
|
||||
return __GT_key.call(null,ns,key_name);
|
||||
} else {
|
||||
if(cljs.core._EQ_.call(null,"_",key_ns)){
|
||||
return __GT_key.call(null,key_name);
|
||||
} else {
|
||||
return key;
|
||||
|
||||
}
|
||||
}
|
||||
})():key));
|
||||
|
||||
var G__21670 = (i__21662 + (1));
|
||||
i__21662 = G__21670;
|
||||
continue;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
})()){
|
||||
return cljs.core.chunk_cons.call(null,cljs.core.chunk.call(null,b__21663),cljs$tools$reader$impl$utils$namespace_keys_$_iter__21660.call(null,cljs.core.chunk_rest.call(null,s__21661__$2)));
|
||||
} else {
|
||||
return cljs.core.chunk_cons.call(null,cljs.core.chunk.call(null,b__21663),null);
|
||||
}
|
||||
} else {
|
||||
var key = cljs.core.first.call(null,s__21661__$2);
|
||||
return cljs.core.cons.call(null,(((((key instanceof cljs.core.Symbol)) || ((key instanceof cljs.core.Keyword))))?(function (){var vec__21667 = cljs.core.juxt.call(null,cljs.core.namespace,cljs.core.name).call(null,key);
|
||||
var key_ns = cljs.core.nth.call(null,vec__21667,(0),null);
|
||||
var key_name = cljs.core.nth.call(null,vec__21667,(1),null);
|
||||
var __GT_key = (((key instanceof cljs.core.Symbol))?cljs.core.symbol:cljs.core.keyword);
|
||||
if((key_ns == null)){
|
||||
return __GT_key.call(null,ns,key_name);
|
||||
} else {
|
||||
if(cljs.core._EQ_.call(null,"_",key_ns)){
|
||||
return __GT_key.call(null,key_name);
|
||||
} else {
|
||||
return key;
|
||||
|
||||
}
|
||||
}
|
||||
})():key),cljs$tools$reader$impl$utils$namespace_keys_$_iter__21660.call(null,cljs.core.rest.call(null,s__21661__$2)));
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}),null,null));
|
||||
});
|
||||
return iter__4523__auto__.call(null,keys);
|
||||
});
|
||||
cljs.tools.reader.impl.utils.second_SINGLEQUOTE_ = (function cljs$tools$reader$impl$utils$second_SINGLEQUOTE_(p__21671){
|
||||
var vec__21672 = p__21671;
|
||||
var a = cljs.core.nth.call(null,vec__21672,(0),null);
|
||||
var b = cljs.core.nth.call(null,vec__21672,(1),null);
|
||||
if(cljs.core.truth_(a)){
|
||||
return null;
|
||||
} else {
|
||||
return b;
|
||||
}
|
||||
});
|
||||
cljs.tools.reader.impl.utils.char_code = (function cljs$tools$reader$impl$utils$char_code(ch,base){
|
||||
var code = parseInt(ch,base);
|
||||
if(cljs.core.truth_(isNaN(code))){
|
||||
return (-1);
|
||||
} else {
|
||||
return code;
|
||||
}
|
||||
});
|
||||
|
||||
//# sourceMappingURL=utils.js.map
|
||||
File diff suppressed because one or more lines are too long
|
|
@ -0,0 +1,283 @@
|
|||
;; Copyright (c) Nicola Mometto, Rich Hickey & contributors.
|
||||
;; The use and distribution terms for this software are covered by the
|
||||
;; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
|
||||
;; which can be found in the file epl-v10.html at the root of this distribution.
|
||||
;; By using this software in any fashion, you are agreeing to be bound by
|
||||
;; the terms of this license.
|
||||
;; You must not remove this notice, or any other, from this software.
|
||||
|
||||
(ns ^{:doc "Protocols and default Reader types implementation"
|
||||
:author "Bronsa"}
|
||||
cljs.tools.reader.reader-types
|
||||
(:refer-clojure :exclude [char read-line])
|
||||
(:require [cljs.tools.reader.impl.utils :refer [char whitespace? newline?]]
|
||||
[goog.string])
|
||||
(:import goog.string.StringBuffer))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; reader protocols
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(defprotocol Reader
|
||||
(read-char [reader]
|
||||
"Returns the next char from the Reader, nil if the end of stream has been reached")
|
||||
(peek-char [reader]
|
||||
"Returns the next char from the Reader without removing it from the reader stream"))
|
||||
|
||||
(defprotocol IPushbackReader
|
||||
(unread [reader ch]
|
||||
"Pushes back a single character on to the stream"))
|
||||
|
||||
(defprotocol IndexingReader
|
||||
(get-line-number [reader]
|
||||
"Returns the line number of the next character to be read from the stream")
|
||||
(get-column-number [reader]
|
||||
"Returns the column number of the next character to be read from the stream")
|
||||
(get-file-name [reader]
|
||||
"Returns the file name the reader is reading from, or nil"))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; reader deftypes
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(deftype StringReader
|
||||
[s s-len ^:mutable s-pos]
|
||||
Reader
|
||||
(read-char [reader]
|
||||
(when (> s-len s-pos)
|
||||
(let [r (.charAt s s-pos)]
|
||||
(set! s-pos (inc s-pos))
|
||||
r)))
|
||||
(peek-char [reader]
|
||||
(when (> s-len s-pos)
|
||||
(.charAt s s-pos))))
|
||||
|
||||
(deftype NodeReadableReader [readable ^:mutable buf]
|
||||
Reader
|
||||
(read-char [reader]
|
||||
(if buf
|
||||
(let [c (aget buf 0)]
|
||||
(set! buf nil)
|
||||
(char c))
|
||||
(let [c (str (.read readable 1))]
|
||||
(when c
|
||||
(char c)))))
|
||||
(peek-char [reader]
|
||||
(when-not buf
|
||||
(set! buf (str (.read readable 1))))
|
||||
(when buf
|
||||
(char (aget buf 0)))))
|
||||
|
||||
(deftype PushbackReader
|
||||
[^not-native rdr buf buf-len ^:mutable buf-pos]
|
||||
Reader
|
||||
(read-char [reader]
|
||||
(let [c (if (< buf-pos buf-len)
|
||||
(aget buf buf-pos)
|
||||
(read-char rdr))]
|
||||
(when (< buf-pos buf-len)
|
||||
(set! buf-pos (inc buf-pos)))
|
||||
(char c)))
|
||||
(peek-char [reader]
|
||||
(let [c (if (< buf-pos buf-len)
|
||||
(aget buf buf-pos)
|
||||
(peek-char rdr))]
|
||||
(char c)))
|
||||
IPushbackReader
|
||||
(unread [reader ch]
|
||||
(when ch
|
||||
(if (zero? buf-pos) (throw (js/Error. "Pushback buffer is full")))
|
||||
(set! buf-pos (dec buf-pos))
|
||||
(aset buf buf-pos ch))))
|
||||
|
||||
(defn- normalize-newline [^not-native rdr ch]
|
||||
(if (identical? \return ch)
|
||||
(let [c (peek-char rdr)]
|
||||
(when (or (identical? \formfeed c)
|
||||
(identical? \newline c))
|
||||
(read-char rdr))
|
||||
\newline)
|
||||
ch))
|
||||
|
||||
(deftype IndexingPushbackReader
|
||||
[^not-native rdr ^:mutable line ^:mutable column
|
||||
^:mutable line-start? ^:mutable prev
|
||||
^:mutable prev-column file-name]
|
||||
Reader
|
||||
(read-char [reader]
|
||||
(when-let [ch (read-char rdr)]
|
||||
(let [ch (normalize-newline rdr ch)]
|
||||
(set! prev line-start?)
|
||||
(set! line-start? (newline? ch))
|
||||
(when line-start?
|
||||
(set! prev-column column)
|
||||
(set! column 0)
|
||||
(set! line (inc line)))
|
||||
(set! column (inc column))
|
||||
ch)))
|
||||
|
||||
(peek-char [reader]
|
||||
(peek-char rdr))
|
||||
|
||||
IPushbackReader
|
||||
(unread [reader ch]
|
||||
(if line-start?
|
||||
(do (set! line (dec line))
|
||||
(set! column prev-column))
|
||||
(set! column (dec column)))
|
||||
(set! line-start? prev)
|
||||
(unread rdr ch))
|
||||
|
||||
IndexingReader
|
||||
(get-line-number [reader] (int line))
|
||||
(get-column-number [reader] (int column))
|
||||
(get-file-name [reader] file-name))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; Source Logging support
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
(defn merge-meta
|
||||
"Returns an object of the same type and value as `obj`, with its
|
||||
metadata merged over `m`."
|
||||
[obj m]
|
||||
(let [orig-meta (meta obj)]
|
||||
(with-meta obj (merge m (dissoc orig-meta :source)))))
|
||||
|
||||
(defn- peek-source-log
|
||||
"Returns a string containing the contents of the top most source
|
||||
logging frame."
|
||||
[frames]
|
||||
(subs (str (:buffer frames)) (first (:offset frames))))
|
||||
|
||||
(defn- log-source-char
|
||||
"Logs `char` to all currently active source logging frames."
|
||||
[frames char]
|
||||
(when-let [buffer (:buffer frames)]
|
||||
(.append buffer char)))
|
||||
|
||||
(defn- drop-last-logged-char
|
||||
"Removes the last logged character from all currently active source
|
||||
logging frames. Called when pushing a character back."
|
||||
[frames]
|
||||
(when-let [buffer (:buffer frames)]
|
||||
(.set buffer (subs (str buffer) 0 (dec (.getLength buffer))))))
|
||||
|
||||
(deftype SourceLoggingPushbackReader
|
||||
[^not-native rdr ^:mutable line ^:mutable column
|
||||
^:mutable line-start? ^:mutable prev
|
||||
^:mutable prev-column file-name frames]
|
||||
Reader
|
||||
(read-char [reader]
|
||||
(when-let [ch (read-char rdr)]
|
||||
(let [ch (normalize-newline rdr ch)]
|
||||
(set! prev line-start?)
|
||||
(set! line-start? (newline? ch))
|
||||
(when line-start?
|
||||
(set! prev-column column)
|
||||
(set! column 0)
|
||||
(set! line (inc line)))
|
||||
(set! column (inc column))
|
||||
(log-source-char @frames ch)
|
||||
ch)))
|
||||
|
||||
(peek-char [reader]
|
||||
(peek-char rdr))
|
||||
|
||||
IPushbackReader
|
||||
(unread [reader ch]
|
||||
(if line-start?
|
||||
(do (set! line (dec line))
|
||||
(set! column prev-column))
|
||||
(set! column (dec column)))
|
||||
(set! line-start? prev)
|
||||
(when ch
|
||||
(drop-last-logged-char @frames))
|
||||
(unread rdr ch))
|
||||
|
||||
IndexingReader
|
||||
(get-line-number [reader] (int line))
|
||||
(get-column-number [reader] (int column))
|
||||
(get-file-name [reader] file-name))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; Public API
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
;; fast check for provided implementations
|
||||
(defn indexing-reader?
|
||||
"Returns true if the reader satisfies IndexingReader"
|
||||
[rdr]
|
||||
(implements? IndexingReader rdr))
|
||||
|
||||
(defn string-reader
|
||||
"Creates a StringReader from a given string"
|
||||
([s]
|
||||
(StringReader. s (count s) 0)))
|
||||
|
||||
(defn string-push-back-reader
|
||||
"Creates a PushbackReader from a given string"
|
||||
([s]
|
||||
(string-push-back-reader s 1))
|
||||
([s buf-len]
|
||||
(PushbackReader. (string-reader s) (object-array buf-len) buf-len buf-len)))
|
||||
|
||||
(defn node-readable-push-back-reader [readable]
|
||||
(PushbackReader. (NodeReadableReader. readable nil) (object-array 1) 1 1))
|
||||
|
||||
(defn indexing-push-back-reader
|
||||
"Creates an IndexingPushbackReader from a given string or PushbackReader"
|
||||
([s-or-rdr]
|
||||
(indexing-push-back-reader s-or-rdr 1))
|
||||
([s-or-rdr buf-len]
|
||||
(indexing-push-back-reader s-or-rdr buf-len nil))
|
||||
([s-or-rdr buf-len file-name]
|
||||
(IndexingPushbackReader.
|
||||
(if (string? s-or-rdr) (string-push-back-reader s-or-rdr buf-len) s-or-rdr) 1 1 true nil 0 file-name)))
|
||||
|
||||
(defn source-logging-push-back-reader
|
||||
"Creates a SourceLoggingPushbackReader from a given string or PushbackReader"
|
||||
([s-or-rdr]
|
||||
(source-logging-push-back-reader s-or-rdr 1))
|
||||
([s-or-rdr buf-len]
|
||||
(source-logging-push-back-reader s-or-rdr buf-len nil))
|
||||
([s-or-rdr buf-len file-name]
|
||||
(SourceLoggingPushbackReader.
|
||||
(if (string? s-or-rdr) (string-push-back-reader s-or-rdr buf-len) s-or-rdr)
|
||||
1
|
||||
1
|
||||
true
|
||||
nil
|
||||
0
|
||||
file-name
|
||||
(atom {:buffer (StringBuffer.) :offset '(0)}))))
|
||||
|
||||
(defn read-line
|
||||
"Reads a line from the reader or from *in* if no reader is specified"
|
||||
([^not-native rdr]
|
||||
(loop [c (read-char rdr) s (StringBuffer.)]
|
||||
(if (newline? c)
|
||||
(str s)
|
||||
(recur (read-char rdr) (.append s c))))))
|
||||
|
||||
(defn ^boolean source-logging-reader?
|
||||
[rdr]
|
||||
(instance? SourceLoggingPushbackReader rdr))
|
||||
|
||||
(defn ^boolean line-start?
|
||||
"Returns true if rdr is an IndexingReader and the current char starts a new line"
|
||||
[^not-native rdr]
|
||||
(when (indexing-reader? rdr)
|
||||
(== 1 (get-column-number rdr))))
|
||||
|
||||
(defn log-source*
|
||||
[reader f]
|
||||
(let [buffer (:buffer @(.-frames reader))]
|
||||
(try
|
||||
(swap! (.-frames reader) update-in [:offset] conj (.getLength buffer))
|
||||
(let [ret (f)]
|
||||
(if (implements? IMeta ret)
|
||||
(merge-meta ret {:source (peek-source-log @ (.-frames reader))})
|
||||
ret))
|
||||
(finally
|
||||
(swap! (.-frames reader) update-in [:offset] rest)))))
|
||||
|
||||
File diff suppressed because one or more lines are too long
|
|
@ -0,0 +1,798 @@
|
|||
// Compiled by ClojureScript 1.10.520 {}
|
||||
goog.provide('cljs.tools.reader.reader_types');
|
||||
goog.require('cljs.core');
|
||||
goog.require('cljs.tools.reader.impl.utils');
|
||||
goog.require('goog.string');
|
||||
goog.require('goog.string.StringBuffer');
|
||||
|
||||
/**
|
||||
* @interface
|
||||
*/
|
||||
cljs.tools.reader.reader_types.Reader = function(){};
|
||||
|
||||
/**
|
||||
* Returns the next char from the Reader, nil if the end of stream has been reached
|
||||
*/
|
||||
cljs.tools.reader.reader_types.read_char = (function cljs$tools$reader$reader_types$read_char(reader){
|
||||
if((((!((reader == null)))) && ((!((reader.cljs$tools$reader$reader_types$Reader$read_char$arity$1 == null)))))){
|
||||
return reader.cljs$tools$reader$reader_types$Reader$read_char$arity$1(reader);
|
||||
} else {
|
||||
var x__4433__auto__ = (((reader == null))?null:reader);
|
||||
var m__4434__auto__ = (cljs.tools.reader.reader_types.read_char[goog.typeOf(x__4433__auto__)]);
|
||||
if((!((m__4434__auto__ == null)))){
|
||||
return m__4434__auto__.call(null,reader);
|
||||
} else {
|
||||
var m__4431__auto__ = (cljs.tools.reader.reader_types.read_char["_"]);
|
||||
if((!((m__4431__auto__ == null)))){
|
||||
return m__4431__auto__.call(null,reader);
|
||||
} else {
|
||||
throw cljs.core.missing_protocol.call(null,"Reader.read-char",reader);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Returns the next char from the Reader without removing it from the reader stream
|
||||
*/
|
||||
cljs.tools.reader.reader_types.peek_char = (function cljs$tools$reader$reader_types$peek_char(reader){
|
||||
if((((!((reader == null)))) && ((!((reader.cljs$tools$reader$reader_types$Reader$peek_char$arity$1 == null)))))){
|
||||
return reader.cljs$tools$reader$reader_types$Reader$peek_char$arity$1(reader);
|
||||
} else {
|
||||
var x__4433__auto__ = (((reader == null))?null:reader);
|
||||
var m__4434__auto__ = (cljs.tools.reader.reader_types.peek_char[goog.typeOf(x__4433__auto__)]);
|
||||
if((!((m__4434__auto__ == null)))){
|
||||
return m__4434__auto__.call(null,reader);
|
||||
} else {
|
||||
var m__4431__auto__ = (cljs.tools.reader.reader_types.peek_char["_"]);
|
||||
if((!((m__4431__auto__ == null)))){
|
||||
return m__4431__auto__.call(null,reader);
|
||||
} else {
|
||||
throw cljs.core.missing_protocol.call(null,"Reader.peek-char",reader);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* @interface
|
||||
*/
|
||||
cljs.tools.reader.reader_types.IPushbackReader = function(){};
|
||||
|
||||
/**
|
||||
* Pushes back a single character on to the stream
|
||||
*/
|
||||
cljs.tools.reader.reader_types.unread = (function cljs$tools$reader$reader_types$unread(reader,ch){
|
||||
if((((!((reader == null)))) && ((!((reader.cljs$tools$reader$reader_types$IPushbackReader$unread$arity$2 == null)))))){
|
||||
return reader.cljs$tools$reader$reader_types$IPushbackReader$unread$arity$2(reader,ch);
|
||||
} else {
|
||||
var x__4433__auto__ = (((reader == null))?null:reader);
|
||||
var m__4434__auto__ = (cljs.tools.reader.reader_types.unread[goog.typeOf(x__4433__auto__)]);
|
||||
if((!((m__4434__auto__ == null)))){
|
||||
return m__4434__auto__.call(null,reader,ch);
|
||||
} else {
|
||||
var m__4431__auto__ = (cljs.tools.reader.reader_types.unread["_"]);
|
||||
if((!((m__4431__auto__ == null)))){
|
||||
return m__4431__auto__.call(null,reader,ch);
|
||||
} else {
|
||||
throw cljs.core.missing_protocol.call(null,"IPushbackReader.unread",reader);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* @interface
|
||||
*/
|
||||
cljs.tools.reader.reader_types.IndexingReader = function(){};
|
||||
|
||||
/**
|
||||
* Returns the line number of the next character to be read from the stream
|
||||
*/
|
||||
cljs.tools.reader.reader_types.get_line_number = (function cljs$tools$reader$reader_types$get_line_number(reader){
|
||||
if((((!((reader == null)))) && ((!((reader.cljs$tools$reader$reader_types$IndexingReader$get_line_number$arity$1 == null)))))){
|
||||
return reader.cljs$tools$reader$reader_types$IndexingReader$get_line_number$arity$1(reader);
|
||||
} else {
|
||||
var x__4433__auto__ = (((reader == null))?null:reader);
|
||||
var m__4434__auto__ = (cljs.tools.reader.reader_types.get_line_number[goog.typeOf(x__4433__auto__)]);
|
||||
if((!((m__4434__auto__ == null)))){
|
||||
return m__4434__auto__.call(null,reader);
|
||||
} else {
|
||||
var m__4431__auto__ = (cljs.tools.reader.reader_types.get_line_number["_"]);
|
||||
if((!((m__4431__auto__ == null)))){
|
||||
return m__4431__auto__.call(null,reader);
|
||||
} else {
|
||||
throw cljs.core.missing_protocol.call(null,"IndexingReader.get-line-number",reader);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Returns the column number of the next character to be read from the stream
|
||||
*/
|
||||
cljs.tools.reader.reader_types.get_column_number = (function cljs$tools$reader$reader_types$get_column_number(reader){
|
||||
if((((!((reader == null)))) && ((!((reader.cljs$tools$reader$reader_types$IndexingReader$get_column_number$arity$1 == null)))))){
|
||||
return reader.cljs$tools$reader$reader_types$IndexingReader$get_column_number$arity$1(reader);
|
||||
} else {
|
||||
var x__4433__auto__ = (((reader == null))?null:reader);
|
||||
var m__4434__auto__ = (cljs.tools.reader.reader_types.get_column_number[goog.typeOf(x__4433__auto__)]);
|
||||
if((!((m__4434__auto__ == null)))){
|
||||
return m__4434__auto__.call(null,reader);
|
||||
} else {
|
||||
var m__4431__auto__ = (cljs.tools.reader.reader_types.get_column_number["_"]);
|
||||
if((!((m__4431__auto__ == null)))){
|
||||
return m__4431__auto__.call(null,reader);
|
||||
} else {
|
||||
throw cljs.core.missing_protocol.call(null,"IndexingReader.get-column-number",reader);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Returns the file name the reader is reading from, or nil
|
||||
*/
|
||||
cljs.tools.reader.reader_types.get_file_name = (function cljs$tools$reader$reader_types$get_file_name(reader){
|
||||
if((((!((reader == null)))) && ((!((reader.cljs$tools$reader$reader_types$IndexingReader$get_file_name$arity$1 == null)))))){
|
||||
return reader.cljs$tools$reader$reader_types$IndexingReader$get_file_name$arity$1(reader);
|
||||
} else {
|
||||
var x__4433__auto__ = (((reader == null))?null:reader);
|
||||
var m__4434__auto__ = (cljs.tools.reader.reader_types.get_file_name[goog.typeOf(x__4433__auto__)]);
|
||||
if((!((m__4434__auto__ == null)))){
|
||||
return m__4434__auto__.call(null,reader);
|
||||
} else {
|
||||
var m__4431__auto__ = (cljs.tools.reader.reader_types.get_file_name["_"]);
|
||||
if((!((m__4431__auto__ == null)))){
|
||||
return m__4431__auto__.call(null,reader);
|
||||
} else {
|
||||
throw cljs.core.missing_protocol.call(null,"IndexingReader.get-file-name",reader);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @implements {cljs.tools.reader.reader_types.Reader}
|
||||
*/
|
||||
cljs.tools.reader.reader_types.StringReader = (function (s,s_len,s_pos){
|
||||
this.s = s;
|
||||
this.s_len = s_len;
|
||||
this.s_pos = s_pos;
|
||||
});
|
||||
cljs.tools.reader.reader_types.StringReader.prototype.cljs$tools$reader$reader_types$Reader$ = cljs.core.PROTOCOL_SENTINEL;
|
||||
|
||||
cljs.tools.reader.reader_types.StringReader.prototype.cljs$tools$reader$reader_types$Reader$read_char$arity$1 = (function (reader){
|
||||
var self__ = this;
|
||||
var reader__$1 = this;
|
||||
if((self__.s_len > self__.s_pos)){
|
||||
var r = self__.s.charAt(self__.s_pos);
|
||||
self__.s_pos = (self__.s_pos + (1));
|
||||
|
||||
return r;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
cljs.tools.reader.reader_types.StringReader.prototype.cljs$tools$reader$reader_types$Reader$peek_char$arity$1 = (function (reader){
|
||||
var self__ = this;
|
||||
var reader__$1 = this;
|
||||
if((self__.s_len > self__.s_pos)){
|
||||
return self__.s.charAt(self__.s_pos);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
cljs.tools.reader.reader_types.StringReader.getBasis = (function (){
|
||||
return new cljs.core.PersistentVector(null, 3, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Symbol(null,"s","s",-948495851,null),new cljs.core.Symbol(null,"s-len","s-len",1869978331,null),cljs.core.with_meta(new cljs.core.Symbol(null,"s-pos","s-pos",-540562492,null),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"mutable","mutable",875778266),true], null))], null);
|
||||
});
|
||||
|
||||
cljs.tools.reader.reader_types.StringReader.cljs$lang$type = true;
|
||||
|
||||
cljs.tools.reader.reader_types.StringReader.cljs$lang$ctorStr = "cljs.tools.reader.reader-types/StringReader";
|
||||
|
||||
cljs.tools.reader.reader_types.StringReader.cljs$lang$ctorPrWriter = (function (this__4374__auto__,writer__4375__auto__,opt__4376__auto__){
|
||||
return cljs.core._write.call(null,writer__4375__auto__,"cljs.tools.reader.reader-types/StringReader");
|
||||
});
|
||||
|
||||
/**
|
||||
* Positional factory function for cljs.tools.reader.reader-types/StringReader.
|
||||
*/
|
||||
cljs.tools.reader.reader_types.__GT_StringReader = (function cljs$tools$reader$reader_types$__GT_StringReader(s,s_len,s_pos){
|
||||
return (new cljs.tools.reader.reader_types.StringReader(s,s_len,s_pos));
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @implements {cljs.tools.reader.reader_types.Reader}
|
||||
*/
|
||||
cljs.tools.reader.reader_types.NodeReadableReader = (function (readable,buf){
|
||||
this.readable = readable;
|
||||
this.buf = buf;
|
||||
});
|
||||
cljs.tools.reader.reader_types.NodeReadableReader.prototype.cljs$tools$reader$reader_types$Reader$ = cljs.core.PROTOCOL_SENTINEL;
|
||||
|
||||
cljs.tools.reader.reader_types.NodeReadableReader.prototype.cljs$tools$reader$reader_types$Reader$read_char$arity$1 = (function (reader){
|
||||
var self__ = this;
|
||||
var reader__$1 = this;
|
||||
if(cljs.core.truth_(self__.buf)){
|
||||
var c = (self__.buf[(0)]);
|
||||
self__.buf = null;
|
||||
|
||||
return cljs.tools.reader.impl.utils.char$.call(null,c);
|
||||
} else {
|
||||
var c = cljs.core.str.cljs$core$IFn$_invoke$arity$1(self__.readable.read((1)));
|
||||
if(cljs.core.truth_(c)){
|
||||
return cljs.tools.reader.impl.utils.char$.call(null,c);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
cljs.tools.reader.reader_types.NodeReadableReader.prototype.cljs$tools$reader$reader_types$Reader$peek_char$arity$1 = (function (reader){
|
||||
var self__ = this;
|
||||
var reader__$1 = this;
|
||||
if(cljs.core.truth_(self__.buf)){
|
||||
} else {
|
||||
self__.buf = cljs.core.str.cljs$core$IFn$_invoke$arity$1(self__.readable.read((1)));
|
||||
}
|
||||
|
||||
if(cljs.core.truth_(self__.buf)){
|
||||
return cljs.tools.reader.impl.utils.char$.call(null,(self__.buf[(0)]));
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
cljs.tools.reader.reader_types.NodeReadableReader.getBasis = (function (){
|
||||
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Symbol(null,"readable","readable",2113054478,null),cljs.core.with_meta(new cljs.core.Symbol(null,"buf","buf",1426618187,null),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"mutable","mutable",875778266),true], null))], null);
|
||||
});
|
||||
|
||||
cljs.tools.reader.reader_types.NodeReadableReader.cljs$lang$type = true;
|
||||
|
||||
cljs.tools.reader.reader_types.NodeReadableReader.cljs$lang$ctorStr = "cljs.tools.reader.reader-types/NodeReadableReader";
|
||||
|
||||
cljs.tools.reader.reader_types.NodeReadableReader.cljs$lang$ctorPrWriter = (function (this__4374__auto__,writer__4375__auto__,opt__4376__auto__){
|
||||
return cljs.core._write.call(null,writer__4375__auto__,"cljs.tools.reader.reader-types/NodeReadableReader");
|
||||
});
|
||||
|
||||
/**
|
||||
* Positional factory function for cljs.tools.reader.reader-types/NodeReadableReader.
|
||||
*/
|
||||
cljs.tools.reader.reader_types.__GT_NodeReadableReader = (function cljs$tools$reader$reader_types$__GT_NodeReadableReader(readable,buf){
|
||||
return (new cljs.tools.reader.reader_types.NodeReadableReader(readable,buf));
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @implements {cljs.tools.reader.reader_types.Reader}
|
||||
* @implements {cljs.tools.reader.reader_types.IPushbackReader}
|
||||
*/
|
||||
cljs.tools.reader.reader_types.PushbackReader = (function (rdr,buf,buf_len,buf_pos){
|
||||
this.rdr = rdr;
|
||||
this.buf = buf;
|
||||
this.buf_len = buf_len;
|
||||
this.buf_pos = buf_pos;
|
||||
});
|
||||
cljs.tools.reader.reader_types.PushbackReader.prototype.cljs$tools$reader$reader_types$Reader$ = cljs.core.PROTOCOL_SENTINEL;
|
||||
|
||||
cljs.tools.reader.reader_types.PushbackReader.prototype.cljs$tools$reader$reader_types$Reader$read_char$arity$1 = (function (reader){
|
||||
var self__ = this;
|
||||
var reader__$1 = this;
|
||||
var c = (((self__.buf_pos < self__.buf_len))?(self__.buf[self__.buf_pos]):cljs.tools.reader.reader_types.read_char.call(null,self__.rdr));
|
||||
if((self__.buf_pos < self__.buf_len)){
|
||||
self__.buf_pos = (self__.buf_pos + (1));
|
||||
} else {
|
||||
}
|
||||
|
||||
return cljs.tools.reader.impl.utils.char$.call(null,c);
|
||||
});
|
||||
|
||||
cljs.tools.reader.reader_types.PushbackReader.prototype.cljs$tools$reader$reader_types$Reader$peek_char$arity$1 = (function (reader){
|
||||
var self__ = this;
|
||||
var reader__$1 = this;
|
||||
var c = (((self__.buf_pos < self__.buf_len))?(self__.buf[self__.buf_pos]):cljs.tools.reader.reader_types.peek_char.call(null,self__.rdr));
|
||||
return cljs.tools.reader.impl.utils.char$.call(null,c);
|
||||
});
|
||||
|
||||
cljs.tools.reader.reader_types.PushbackReader.prototype.cljs$tools$reader$reader_types$IPushbackReader$ = cljs.core.PROTOCOL_SENTINEL;
|
||||
|
||||
cljs.tools.reader.reader_types.PushbackReader.prototype.cljs$tools$reader$reader_types$IPushbackReader$unread$arity$2 = (function (reader,ch){
|
||||
var self__ = this;
|
||||
var reader__$1 = this;
|
||||
if(cljs.core.truth_(ch)){
|
||||
if((self__.buf_pos === (0))){
|
||||
throw (new Error("Pushback buffer is full"));
|
||||
} else {
|
||||
}
|
||||
|
||||
self__.buf_pos = (self__.buf_pos - (1));
|
||||
|
||||
return (self__.buf[self__.buf_pos] = ch);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
cljs.tools.reader.reader_types.PushbackReader.getBasis = (function (){
|
||||
return new cljs.core.PersistentVector(null, 4, 5, cljs.core.PersistentVector.EMPTY_NODE, [cljs.core.with_meta(new cljs.core.Symbol(null,"rdr","rdr",190007785,null),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"tag","tag",-1290361223),new cljs.core.Symbol(null,"not-native","not-native",-236392494,null)], null)),new cljs.core.Symbol(null,"buf","buf",1426618187,null),new cljs.core.Symbol(null,"buf-len","buf-len",404510846,null),cljs.core.with_meta(new cljs.core.Symbol(null,"buf-pos","buf-pos",-807229033,null),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"mutable","mutable",875778266),true], null))], null);
|
||||
});
|
||||
|
||||
cljs.tools.reader.reader_types.PushbackReader.cljs$lang$type = true;
|
||||
|
||||
cljs.tools.reader.reader_types.PushbackReader.cljs$lang$ctorStr = "cljs.tools.reader.reader-types/PushbackReader";
|
||||
|
||||
cljs.tools.reader.reader_types.PushbackReader.cljs$lang$ctorPrWriter = (function (this__4374__auto__,writer__4375__auto__,opt__4376__auto__){
|
||||
return cljs.core._write.call(null,writer__4375__auto__,"cljs.tools.reader.reader-types/PushbackReader");
|
||||
});
|
||||
|
||||
/**
|
||||
* Positional factory function for cljs.tools.reader.reader-types/PushbackReader.
|
||||
*/
|
||||
cljs.tools.reader.reader_types.__GT_PushbackReader = (function cljs$tools$reader$reader_types$__GT_PushbackReader(rdr,buf,buf_len,buf_pos){
|
||||
return (new cljs.tools.reader.reader_types.PushbackReader(rdr,buf,buf_len,buf_pos));
|
||||
});
|
||||
|
||||
cljs.tools.reader.reader_types.normalize_newline = (function cljs$tools$reader$reader_types$normalize_newline(rdr,ch){
|
||||
if(("\r" === ch)){
|
||||
var c = cljs.tools.reader.reader_types.peek_char.call(null,rdr);
|
||||
if(((("\f" === c)) || (("\n" === c)))){
|
||||
cljs.tools.reader.reader_types.read_char.call(null,rdr);
|
||||
} else {
|
||||
}
|
||||
|
||||
return "\n";
|
||||
} else {
|
||||
return ch;
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @implements {cljs.tools.reader.reader_types.IndexingReader}
|
||||
* @implements {cljs.tools.reader.reader_types.Reader}
|
||||
* @implements {cljs.tools.reader.reader_types.IPushbackReader}
|
||||
*/
|
||||
cljs.tools.reader.reader_types.IndexingPushbackReader = (function (rdr,line,column,line_start_QMARK_,prev,prev_column,file_name){
|
||||
this.rdr = rdr;
|
||||
this.line = line;
|
||||
this.column = column;
|
||||
this.line_start_QMARK_ = line_start_QMARK_;
|
||||
this.prev = prev;
|
||||
this.prev_column = prev_column;
|
||||
this.file_name = file_name;
|
||||
});
|
||||
cljs.tools.reader.reader_types.IndexingPushbackReader.prototype.cljs$tools$reader$reader_types$Reader$ = cljs.core.PROTOCOL_SENTINEL;
|
||||
|
||||
cljs.tools.reader.reader_types.IndexingPushbackReader.prototype.cljs$tools$reader$reader_types$Reader$read_char$arity$1 = (function (reader){
|
||||
var self__ = this;
|
||||
var reader__$1 = this;
|
||||
var temp__5720__auto__ = cljs.tools.reader.reader_types.read_char.call(null,self__.rdr);
|
||||
if(cljs.core.truth_(temp__5720__auto__)){
|
||||
var ch = temp__5720__auto__;
|
||||
var ch__$1 = cljs.tools.reader.reader_types.normalize_newline.call(null,self__.rdr,ch);
|
||||
self__.prev = self__.line_start_QMARK_;
|
||||
|
||||
self__.line_start_QMARK_ = cljs.tools.reader.impl.utils.newline_QMARK_.call(null,ch__$1);
|
||||
|
||||
if(cljs.core.truth_(self__.line_start_QMARK_)){
|
||||
self__.prev_column = self__.column;
|
||||
|
||||
self__.column = (0);
|
||||
|
||||
self__.line = (self__.line + (1));
|
||||
} else {
|
||||
}
|
||||
|
||||
self__.column = (self__.column + (1));
|
||||
|
||||
return ch__$1;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
cljs.tools.reader.reader_types.IndexingPushbackReader.prototype.cljs$tools$reader$reader_types$Reader$peek_char$arity$1 = (function (reader){
|
||||
var self__ = this;
|
||||
var reader__$1 = this;
|
||||
return cljs.tools.reader.reader_types.peek_char.call(null,self__.rdr);
|
||||
});
|
||||
|
||||
cljs.tools.reader.reader_types.IndexingPushbackReader.prototype.cljs$tools$reader$reader_types$IPushbackReader$ = cljs.core.PROTOCOL_SENTINEL;
|
||||
|
||||
cljs.tools.reader.reader_types.IndexingPushbackReader.prototype.cljs$tools$reader$reader_types$IPushbackReader$unread$arity$2 = (function (reader,ch){
|
||||
var self__ = this;
|
||||
var reader__$1 = this;
|
||||
if(cljs.core.truth_(self__.line_start_QMARK_)){
|
||||
self__.line = (self__.line - (1));
|
||||
|
||||
self__.column = self__.prev_column;
|
||||
} else {
|
||||
self__.column = (self__.column - (1));
|
||||
}
|
||||
|
||||
self__.line_start_QMARK_ = self__.prev;
|
||||
|
||||
return cljs.tools.reader.reader_types.unread.call(null,self__.rdr,ch);
|
||||
});
|
||||
|
||||
cljs.tools.reader.reader_types.IndexingPushbackReader.prototype.cljs$tools$reader$reader_types$IndexingReader$ = cljs.core.PROTOCOL_SENTINEL;
|
||||
|
||||
cljs.tools.reader.reader_types.IndexingPushbackReader.prototype.cljs$tools$reader$reader_types$IndexingReader$get_line_number$arity$1 = (function (reader){
|
||||
var self__ = this;
|
||||
var reader__$1 = this;
|
||||
return (self__.line | (0));
|
||||
});
|
||||
|
||||
cljs.tools.reader.reader_types.IndexingPushbackReader.prototype.cljs$tools$reader$reader_types$IndexingReader$get_column_number$arity$1 = (function (reader){
|
||||
var self__ = this;
|
||||
var reader__$1 = this;
|
||||
return (self__.column | (0));
|
||||
});
|
||||
|
||||
cljs.tools.reader.reader_types.IndexingPushbackReader.prototype.cljs$tools$reader$reader_types$IndexingReader$get_file_name$arity$1 = (function (reader){
|
||||
var self__ = this;
|
||||
var reader__$1 = this;
|
||||
return self__.file_name;
|
||||
});
|
||||
|
||||
cljs.tools.reader.reader_types.IndexingPushbackReader.getBasis = (function (){
|
||||
return new cljs.core.PersistentVector(null, 7, 5, cljs.core.PersistentVector.EMPTY_NODE, [cljs.core.with_meta(new cljs.core.Symbol(null,"rdr","rdr",190007785,null),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"tag","tag",-1290361223),new cljs.core.Symbol(null,"not-native","not-native",-236392494,null)], null)),cljs.core.with_meta(new cljs.core.Symbol(null,"line","line",1852876762,null),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"mutable","mutable",875778266),true], null)),cljs.core.with_meta(new cljs.core.Symbol(null,"column","column",-576213674,null),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"mutable","mutable",875778266),true], null)),cljs.core.with_meta(new cljs.core.Symbol(null,"line-start?","line-start?",1357012474,null),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"mutable","mutable",875778266),true], null)),cljs.core.with_meta(new cljs.core.Symbol(null,"prev","prev",43462301,null),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"mutable","mutable",875778266),true], null)),cljs.core.with_meta(new cljs.core.Symbol(null,"prev-column","prev-column",324083974,null),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"mutable","mutable",875778266),true], null)),new cljs.core.Symbol(null,"file-name","file-name",-13685732,null)], null);
|
||||
});
|
||||
|
||||
cljs.tools.reader.reader_types.IndexingPushbackReader.cljs$lang$type = true;
|
||||
|
||||
cljs.tools.reader.reader_types.IndexingPushbackReader.cljs$lang$ctorStr = "cljs.tools.reader.reader-types/IndexingPushbackReader";
|
||||
|
||||
cljs.tools.reader.reader_types.IndexingPushbackReader.cljs$lang$ctorPrWriter = (function (this__4374__auto__,writer__4375__auto__,opt__4376__auto__){
|
||||
return cljs.core._write.call(null,writer__4375__auto__,"cljs.tools.reader.reader-types/IndexingPushbackReader");
|
||||
});
|
||||
|
||||
/**
|
||||
* Positional factory function for cljs.tools.reader.reader-types/IndexingPushbackReader.
|
||||
*/
|
||||
cljs.tools.reader.reader_types.__GT_IndexingPushbackReader = (function cljs$tools$reader$reader_types$__GT_IndexingPushbackReader(rdr,line,column,line_start_QMARK_,prev,prev_column,file_name){
|
||||
return (new cljs.tools.reader.reader_types.IndexingPushbackReader(rdr,line,column,line_start_QMARK_,prev,prev_column,file_name));
|
||||
});
|
||||
|
||||
/**
|
||||
* Returns an object of the same type and value as `obj`, with its
|
||||
* metadata merged over `m`.
|
||||
*/
|
||||
cljs.tools.reader.reader_types.merge_meta = (function cljs$tools$reader$reader_types$merge_meta(obj,m){
|
||||
var orig_meta = cljs.core.meta.call(null,obj);
|
||||
return cljs.core.with_meta.call(null,obj,cljs.core.merge.call(null,m,cljs.core.dissoc.call(null,orig_meta,new cljs.core.Keyword(null,"source","source",-433931539))));
|
||||
});
|
||||
/**
|
||||
* Returns a string containing the contents of the top most source
|
||||
* logging frame.
|
||||
*/
|
||||
cljs.tools.reader.reader_types.peek_source_log = (function cljs$tools$reader$reader_types$peek_source_log(frames){
|
||||
return cljs.core.subs.call(null,cljs.core.str.cljs$core$IFn$_invoke$arity$1(new cljs.core.Keyword(null,"buffer","buffer",617295198).cljs$core$IFn$_invoke$arity$1(frames)),cljs.core.first.call(null,new cljs.core.Keyword(null,"offset","offset",296498311).cljs$core$IFn$_invoke$arity$1(frames)));
|
||||
});
|
||||
/**
|
||||
* Logs `char` to all currently active source logging frames.
|
||||
*/
|
||||
cljs.tools.reader.reader_types.log_source_char = (function cljs$tools$reader$reader_types$log_source_char(frames,char$){
|
||||
var temp__5720__auto__ = new cljs.core.Keyword(null,"buffer","buffer",617295198).cljs$core$IFn$_invoke$arity$1(frames);
|
||||
if(cljs.core.truth_(temp__5720__auto__)){
|
||||
var buffer = temp__5720__auto__;
|
||||
return buffer.append(char$);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
/**
|
||||
* Removes the last logged character from all currently active source
|
||||
* logging frames. Called when pushing a character back.
|
||||
*/
|
||||
cljs.tools.reader.reader_types.drop_last_logged_char = (function cljs$tools$reader$reader_types$drop_last_logged_char(frames){
|
||||
var temp__5720__auto__ = new cljs.core.Keyword(null,"buffer","buffer",617295198).cljs$core$IFn$_invoke$arity$1(frames);
|
||||
if(cljs.core.truth_(temp__5720__auto__)){
|
||||
var buffer = temp__5720__auto__;
|
||||
return buffer.set(cljs.core.subs.call(null,cljs.core.str.cljs$core$IFn$_invoke$arity$1(buffer),(0),(buffer.getLength() - (1))));
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @implements {cljs.tools.reader.reader_types.IndexingReader}
|
||||
* @implements {cljs.tools.reader.reader_types.Reader}
|
||||
* @implements {cljs.tools.reader.reader_types.IPushbackReader}
|
||||
*/
|
||||
cljs.tools.reader.reader_types.SourceLoggingPushbackReader = (function (rdr,line,column,line_start_QMARK_,prev,prev_column,file_name,frames){
|
||||
this.rdr = rdr;
|
||||
this.line = line;
|
||||
this.column = column;
|
||||
this.line_start_QMARK_ = line_start_QMARK_;
|
||||
this.prev = prev;
|
||||
this.prev_column = prev_column;
|
||||
this.file_name = file_name;
|
||||
this.frames = frames;
|
||||
});
|
||||
cljs.tools.reader.reader_types.SourceLoggingPushbackReader.prototype.cljs$tools$reader$reader_types$Reader$ = cljs.core.PROTOCOL_SENTINEL;
|
||||
|
||||
cljs.tools.reader.reader_types.SourceLoggingPushbackReader.prototype.cljs$tools$reader$reader_types$Reader$read_char$arity$1 = (function (reader){
|
||||
var self__ = this;
|
||||
var reader__$1 = this;
|
||||
var temp__5720__auto__ = cljs.tools.reader.reader_types.read_char.call(null,self__.rdr);
|
||||
if(cljs.core.truth_(temp__5720__auto__)){
|
||||
var ch = temp__5720__auto__;
|
||||
var ch__$1 = cljs.tools.reader.reader_types.normalize_newline.call(null,self__.rdr,ch);
|
||||
self__.prev = self__.line_start_QMARK_;
|
||||
|
||||
self__.line_start_QMARK_ = cljs.tools.reader.impl.utils.newline_QMARK_.call(null,ch__$1);
|
||||
|
||||
if(cljs.core.truth_(self__.line_start_QMARK_)){
|
||||
self__.prev_column = self__.column;
|
||||
|
||||
self__.column = (0);
|
||||
|
||||
self__.line = (self__.line + (1));
|
||||
} else {
|
||||
}
|
||||
|
||||
self__.column = (self__.column + (1));
|
||||
|
||||
cljs.tools.reader.reader_types.log_source_char.call(null,cljs.core.deref.call(null,self__.frames),ch__$1);
|
||||
|
||||
return ch__$1;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
cljs.tools.reader.reader_types.SourceLoggingPushbackReader.prototype.cljs$tools$reader$reader_types$Reader$peek_char$arity$1 = (function (reader){
|
||||
var self__ = this;
|
||||
var reader__$1 = this;
|
||||
return cljs.tools.reader.reader_types.peek_char.call(null,self__.rdr);
|
||||
});
|
||||
|
||||
cljs.tools.reader.reader_types.SourceLoggingPushbackReader.prototype.cljs$tools$reader$reader_types$IPushbackReader$ = cljs.core.PROTOCOL_SENTINEL;
|
||||
|
||||
cljs.tools.reader.reader_types.SourceLoggingPushbackReader.prototype.cljs$tools$reader$reader_types$IPushbackReader$unread$arity$2 = (function (reader,ch){
|
||||
var self__ = this;
|
||||
var reader__$1 = this;
|
||||
if(cljs.core.truth_(self__.line_start_QMARK_)){
|
||||
self__.line = (self__.line - (1));
|
||||
|
||||
self__.column = self__.prev_column;
|
||||
} else {
|
||||
self__.column = (self__.column - (1));
|
||||
}
|
||||
|
||||
self__.line_start_QMARK_ = self__.prev;
|
||||
|
||||
if(cljs.core.truth_(ch)){
|
||||
cljs.tools.reader.reader_types.drop_last_logged_char.call(null,cljs.core.deref.call(null,self__.frames));
|
||||
} else {
|
||||
}
|
||||
|
||||
return cljs.tools.reader.reader_types.unread.call(null,self__.rdr,ch);
|
||||
});
|
||||
|
||||
cljs.tools.reader.reader_types.SourceLoggingPushbackReader.prototype.cljs$tools$reader$reader_types$IndexingReader$ = cljs.core.PROTOCOL_SENTINEL;
|
||||
|
||||
cljs.tools.reader.reader_types.SourceLoggingPushbackReader.prototype.cljs$tools$reader$reader_types$IndexingReader$get_line_number$arity$1 = (function (reader){
|
||||
var self__ = this;
|
||||
var reader__$1 = this;
|
||||
return (self__.line | (0));
|
||||
});
|
||||
|
||||
cljs.tools.reader.reader_types.SourceLoggingPushbackReader.prototype.cljs$tools$reader$reader_types$IndexingReader$get_column_number$arity$1 = (function (reader){
|
||||
var self__ = this;
|
||||
var reader__$1 = this;
|
||||
return (self__.column | (0));
|
||||
});
|
||||
|
||||
cljs.tools.reader.reader_types.SourceLoggingPushbackReader.prototype.cljs$tools$reader$reader_types$IndexingReader$get_file_name$arity$1 = (function (reader){
|
||||
var self__ = this;
|
||||
var reader__$1 = this;
|
||||
return self__.file_name;
|
||||
});
|
||||
|
||||
cljs.tools.reader.reader_types.SourceLoggingPushbackReader.getBasis = (function (){
|
||||
return new cljs.core.PersistentVector(null, 8, 5, cljs.core.PersistentVector.EMPTY_NODE, [cljs.core.with_meta(new cljs.core.Symbol(null,"rdr","rdr",190007785,null),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"tag","tag",-1290361223),new cljs.core.Symbol(null,"not-native","not-native",-236392494,null)], null)),cljs.core.with_meta(new cljs.core.Symbol(null,"line","line",1852876762,null),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"mutable","mutable",875778266),true], null)),cljs.core.with_meta(new cljs.core.Symbol(null,"column","column",-576213674,null),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"mutable","mutable",875778266),true], null)),cljs.core.with_meta(new cljs.core.Symbol(null,"line-start?","line-start?",1357012474,null),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"mutable","mutable",875778266),true], null)),cljs.core.with_meta(new cljs.core.Symbol(null,"prev","prev",43462301,null),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"mutable","mutable",875778266),true], null)),cljs.core.with_meta(new cljs.core.Symbol(null,"prev-column","prev-column",324083974,null),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"mutable","mutable",875778266),true], null)),new cljs.core.Symbol(null,"file-name","file-name",-13685732,null),new cljs.core.Symbol(null,"frames","frames",-888748272,null)], null);
|
||||
});
|
||||
|
||||
cljs.tools.reader.reader_types.SourceLoggingPushbackReader.cljs$lang$type = true;
|
||||
|
||||
cljs.tools.reader.reader_types.SourceLoggingPushbackReader.cljs$lang$ctorStr = "cljs.tools.reader.reader-types/SourceLoggingPushbackReader";
|
||||
|
||||
cljs.tools.reader.reader_types.SourceLoggingPushbackReader.cljs$lang$ctorPrWriter = (function (this__4374__auto__,writer__4375__auto__,opt__4376__auto__){
|
||||
return cljs.core._write.call(null,writer__4375__auto__,"cljs.tools.reader.reader-types/SourceLoggingPushbackReader");
|
||||
});
|
||||
|
||||
/**
|
||||
* Positional factory function for cljs.tools.reader.reader-types/SourceLoggingPushbackReader.
|
||||
*/
|
||||
cljs.tools.reader.reader_types.__GT_SourceLoggingPushbackReader = (function cljs$tools$reader$reader_types$__GT_SourceLoggingPushbackReader(rdr,line,column,line_start_QMARK_,prev,prev_column,file_name,frames){
|
||||
return (new cljs.tools.reader.reader_types.SourceLoggingPushbackReader(rdr,line,column,line_start_QMARK_,prev,prev_column,file_name,frames));
|
||||
});
|
||||
|
||||
/**
|
||||
* Returns true if the reader satisfies IndexingReader
|
||||
*/
|
||||
cljs.tools.reader.reader_types.indexing_reader_QMARK_ = (function cljs$tools$reader$reader_types$indexing_reader_QMARK_(rdr){
|
||||
if((!((rdr == null)))){
|
||||
if(((false) || ((cljs.core.PROTOCOL_SENTINEL === rdr.cljs$tools$reader$reader_types$IndexingReader$)))){
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
/**
|
||||
* Creates a StringReader from a given string
|
||||
*/
|
||||
cljs.tools.reader.reader_types.string_reader = (function cljs$tools$reader$reader_types$string_reader(s){
|
||||
return (new cljs.tools.reader.reader_types.StringReader(s,cljs.core.count.call(null,s),(0)));
|
||||
});
|
||||
/**
|
||||
* Creates a PushbackReader from a given string
|
||||
*/
|
||||
cljs.tools.reader.reader_types.string_push_back_reader = (function cljs$tools$reader$reader_types$string_push_back_reader(var_args){
|
||||
var G__21679 = arguments.length;
|
||||
switch (G__21679) {
|
||||
case 1:
|
||||
return cljs.tools.reader.reader_types.string_push_back_reader.cljs$core$IFn$_invoke$arity$1((arguments[(0)]));
|
||||
|
||||
break;
|
||||
case 2:
|
||||
return cljs.tools.reader.reader_types.string_push_back_reader.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)]));
|
||||
|
||||
break;
|
||||
default:
|
||||
throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
cljs.tools.reader.reader_types.string_push_back_reader.cljs$core$IFn$_invoke$arity$1 = (function (s){
|
||||
return cljs.tools.reader.reader_types.string_push_back_reader.call(null,s,(1));
|
||||
});
|
||||
|
||||
cljs.tools.reader.reader_types.string_push_back_reader.cljs$core$IFn$_invoke$arity$2 = (function (s,buf_len){
|
||||
return (new cljs.tools.reader.reader_types.PushbackReader(cljs.tools.reader.reader_types.string_reader.call(null,s),cljs.core.object_array.call(null,buf_len),buf_len,buf_len));
|
||||
});
|
||||
|
||||
cljs.tools.reader.reader_types.string_push_back_reader.cljs$lang$maxFixedArity = 2;
|
||||
|
||||
cljs.tools.reader.reader_types.node_readable_push_back_reader = (function cljs$tools$reader$reader_types$node_readable_push_back_reader(readable){
|
||||
return (new cljs.tools.reader.reader_types.PushbackReader((new cljs.tools.reader.reader_types.NodeReadableReader(readable,null)),cljs.core.object_array.call(null,(1)),(1),(1)));
|
||||
});
|
||||
/**
|
||||
* Creates an IndexingPushbackReader from a given string or PushbackReader
|
||||
*/
|
||||
cljs.tools.reader.reader_types.indexing_push_back_reader = (function cljs$tools$reader$reader_types$indexing_push_back_reader(var_args){
|
||||
var G__21682 = arguments.length;
|
||||
switch (G__21682) {
|
||||
case 1:
|
||||
return cljs.tools.reader.reader_types.indexing_push_back_reader.cljs$core$IFn$_invoke$arity$1((arguments[(0)]));
|
||||
|
||||
break;
|
||||
case 2:
|
||||
return cljs.tools.reader.reader_types.indexing_push_back_reader.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)]));
|
||||
|
||||
break;
|
||||
case 3:
|
||||
return cljs.tools.reader.reader_types.indexing_push_back_reader.cljs$core$IFn$_invoke$arity$3((arguments[(0)]),(arguments[(1)]),(arguments[(2)]));
|
||||
|
||||
break;
|
||||
default:
|
||||
throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
cljs.tools.reader.reader_types.indexing_push_back_reader.cljs$core$IFn$_invoke$arity$1 = (function (s_or_rdr){
|
||||
return cljs.tools.reader.reader_types.indexing_push_back_reader.call(null,s_or_rdr,(1));
|
||||
});
|
||||
|
||||
cljs.tools.reader.reader_types.indexing_push_back_reader.cljs$core$IFn$_invoke$arity$2 = (function (s_or_rdr,buf_len){
|
||||
return cljs.tools.reader.reader_types.indexing_push_back_reader.call(null,s_or_rdr,buf_len,null);
|
||||
});
|
||||
|
||||
cljs.tools.reader.reader_types.indexing_push_back_reader.cljs$core$IFn$_invoke$arity$3 = (function (s_or_rdr,buf_len,file_name){
|
||||
return (new cljs.tools.reader.reader_types.IndexingPushbackReader(((typeof s_or_rdr === 'string')?cljs.tools.reader.reader_types.string_push_back_reader.call(null,s_or_rdr,buf_len):s_or_rdr),(1),(1),true,null,(0),file_name));
|
||||
});
|
||||
|
||||
cljs.tools.reader.reader_types.indexing_push_back_reader.cljs$lang$maxFixedArity = 3;
|
||||
|
||||
/**
|
||||
* Creates a SourceLoggingPushbackReader from a given string or PushbackReader
|
||||
*/
|
||||
cljs.tools.reader.reader_types.source_logging_push_back_reader = (function cljs$tools$reader$reader_types$source_logging_push_back_reader(var_args){
|
||||
var G__21685 = arguments.length;
|
||||
switch (G__21685) {
|
||||
case 1:
|
||||
return cljs.tools.reader.reader_types.source_logging_push_back_reader.cljs$core$IFn$_invoke$arity$1((arguments[(0)]));
|
||||
|
||||
break;
|
||||
case 2:
|
||||
return cljs.tools.reader.reader_types.source_logging_push_back_reader.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)]));
|
||||
|
||||
break;
|
||||
case 3:
|
||||
return cljs.tools.reader.reader_types.source_logging_push_back_reader.cljs$core$IFn$_invoke$arity$3((arguments[(0)]),(arguments[(1)]),(arguments[(2)]));
|
||||
|
||||
break;
|
||||
default:
|
||||
throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
cljs.tools.reader.reader_types.source_logging_push_back_reader.cljs$core$IFn$_invoke$arity$1 = (function (s_or_rdr){
|
||||
return cljs.tools.reader.reader_types.source_logging_push_back_reader.call(null,s_or_rdr,(1));
|
||||
});
|
||||
|
||||
cljs.tools.reader.reader_types.source_logging_push_back_reader.cljs$core$IFn$_invoke$arity$2 = (function (s_or_rdr,buf_len){
|
||||
return cljs.tools.reader.reader_types.source_logging_push_back_reader.call(null,s_or_rdr,buf_len,null);
|
||||
});
|
||||
|
||||
cljs.tools.reader.reader_types.source_logging_push_back_reader.cljs$core$IFn$_invoke$arity$3 = (function (s_or_rdr,buf_len,file_name){
|
||||
return (new cljs.tools.reader.reader_types.SourceLoggingPushbackReader(((typeof s_or_rdr === 'string')?cljs.tools.reader.reader_types.string_push_back_reader.call(null,s_or_rdr,buf_len):s_or_rdr),(1),(1),true,null,(0),file_name,cljs.core.atom.call(null,new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"buffer","buffer",617295198),(new goog.string.StringBuffer()),new cljs.core.Keyword(null,"offset","offset",296498311),cljs.core.list((0))], null))));
|
||||
});
|
||||
|
||||
cljs.tools.reader.reader_types.source_logging_push_back_reader.cljs$lang$maxFixedArity = 3;
|
||||
|
||||
/**
|
||||
* Reads a line from the reader or from *in* if no reader is specified
|
||||
*/
|
||||
cljs.tools.reader.reader_types.read_line = (function cljs$tools$reader$reader_types$read_line(rdr){
|
||||
var c = cljs.tools.reader.reader_types.read_char.call(null,rdr);
|
||||
var s = (new goog.string.StringBuffer());
|
||||
while(true){
|
||||
if(cljs.tools.reader.impl.utils.newline_QMARK_.call(null,c)){
|
||||
return cljs.core.str.cljs$core$IFn$_invoke$arity$1(s);
|
||||
} else {
|
||||
var G__21687 = cljs.tools.reader.reader_types.read_char.call(null,rdr);
|
||||
var G__21688 = s.append(c);
|
||||
c = G__21687;
|
||||
s = G__21688;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
});
|
||||
cljs.tools.reader.reader_types.source_logging_reader_QMARK_ = (function cljs$tools$reader$reader_types$source_logging_reader_QMARK_(rdr){
|
||||
return (rdr instanceof cljs.tools.reader.reader_types.SourceLoggingPushbackReader);
|
||||
});
|
||||
/**
|
||||
* Returns true if rdr is an IndexingReader and the current char starts a new line
|
||||
*/
|
||||
cljs.tools.reader.reader_types.line_start_QMARK_ = (function cljs$tools$reader$reader_types$line_start_QMARK_(rdr){
|
||||
if(cljs.tools.reader.reader_types.indexing_reader_QMARK_.call(null,rdr)){
|
||||
return ((1) === cljs.tools.reader.reader_types.get_column_number.call(null,rdr));
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
cljs.tools.reader.reader_types.log_source_STAR_ = (function cljs$tools$reader$reader_types$log_source_STAR_(reader,f){
|
||||
var buffer = new cljs.core.Keyword(null,"buffer","buffer",617295198).cljs$core$IFn$_invoke$arity$1(cljs.core.deref.call(null,reader.frames));
|
||||
try{cljs.core.swap_BANG_.call(null,reader.frames,cljs.core.update_in,new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"offset","offset",296498311)], null),cljs.core.conj,buffer.getLength());
|
||||
|
||||
var ret = f.call(null);
|
||||
if((((!((ret == null))))?(((((ret.cljs$lang$protocol_mask$partition0$ & (131072))) || ((cljs.core.PROTOCOL_SENTINEL === ret.cljs$core$IMeta$))))?true:false):false)){
|
||||
return cljs.tools.reader.reader_types.merge_meta.call(null,ret,new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"source","source",-433931539),cljs.tools.reader.reader_types.peek_source_log.call(null,cljs.core.deref.call(null,reader.frames))], null));
|
||||
} else {
|
||||
return ret;
|
||||
}
|
||||
}finally {cljs.core.swap_BANG_.call(null,reader.frames,cljs.core.update_in,new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"offset","offset",296498311)], null),cljs.core.rest);
|
||||
}});
|
||||
|
||||
//# sourceMappingURL=reader_types.js.map
|
||||
File diff suppressed because one or more lines are too long
40
resources/public/target/cljsbuild-compiler-1/cljs_deps.js
Normal file
40
resources/public/target/cljsbuild-compiler-1/cljs_deps.js
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
goog.addDependency("base.js", ['goog'], []);
|
||||
goog.addDependency("../cljs/core.js", ['cljs.core'], ['goog.string', 'goog.Uri', 'goog.object', 'goog.math.Integer', 'goog.string.StringBuffer', 'goog.array', 'goog.math.Long']);
|
||||
goog.addDependency("../process/env.js", ['process.env'], ['cljs.core']);
|
||||
goog.addDependency("../clojure/browser/dom.js", ['clojure.browser.dom'], ['goog.dom', 'cljs.core', 'goog.object']);
|
||||
goog.addDependency("../geocsv_lite/notify.js", ['geocsv_lite.notify'], ['cljs.core', 'clojure.browser.dom']);
|
||||
goog.addDependency("../geocsv_lite/map.js", ['geocsv_lite.map'], ['cljs.core', 'geocsv_lite.notify']);
|
||||
goog.addDependency("../clojure/string.js", ['clojure.string'], ['goog.string', 'cljs.core', 'goog.string.StringBuffer']);
|
||||
goog.addDependency("../cljs/tools/reader/impl/utils.js", ['cljs.tools.reader.impl.utils'], ['goog.string', 'cljs.core', 'clojure.string']);
|
||||
goog.addDependency("../cljs/tools/reader/reader_types.js", ['cljs.tools.reader.reader_types'], ['goog.string', 'cljs.core', 'goog.string.StringBuffer', 'cljs.tools.reader.impl.utils']);
|
||||
goog.addDependency("../cljs/tools/reader/impl/inspect.js", ['cljs.tools.reader.impl.inspect'], ['cljs.core']);
|
||||
goog.addDependency("../cljs/tools/reader/impl/errors.js", ['cljs.tools.reader.impl.errors'], ['cljs.core', 'cljs.tools.reader.reader_types', 'cljs.tools.reader.impl.inspect', 'clojure.string']);
|
||||
goog.addDependency("../cljs/tools/reader/impl/commons.js", ['cljs.tools.reader.impl.commons'], ['cljs.tools.reader.impl.errors', 'cljs.core', 'cljs.tools.reader.reader_types', 'cljs.tools.reader.impl.utils']);
|
||||
goog.addDependency("../cljs/tools/reader.js", ['cljs.tools.reader'], ['cljs.tools.reader.impl.commons', 'goog.string', 'cljs.tools.reader.impl.errors', 'cljs.core', 'cljs.tools.reader.reader_types', 'goog.string.StringBuffer', 'cljs.tools.reader.impl.utils', 'goog.array']);
|
||||
goog.addDependency("../cljs/tools/reader/edn.js", ['cljs.tools.reader.edn'], ['cljs.tools.reader.impl.commons', 'cljs.tools.reader', 'goog.string', 'cljs.tools.reader.impl.errors', 'cljs.core', 'cljs.tools.reader.reader_types', 'goog.string.StringBuffer', 'cljs.tools.reader.impl.utils']);
|
||||
goog.addDependency("../cljs/reader.js", ['cljs.reader'], ['cljs.tools.reader.edn', 'cljs.tools.reader', 'cljs.core', 'goog.object', 'goog.string.StringBuffer']);
|
||||
goog.addDependency("../no/en/core.js", ['no.en.core'], ['cljs.core', 'goog.crypt.base64', 'clojure.string', 'cljs.reader']);
|
||||
goog.addDependency("../com/cognitect/transit/util.js", ['com.cognitect.transit.util'], ['goog.object']);
|
||||
goog.addDependency("../com/cognitect/transit/eq.js", ['com.cognitect.transit.eq'], ['com.cognitect.transit.util']);
|
||||
goog.addDependency("../com/cognitect/transit/types.js", ['com.cognitect.transit.types'], ['com.cognitect.transit.util', 'com.cognitect.transit.eq', 'goog.math.Long']);
|
||||
goog.addDependency("../com/cognitect/transit/delimiters.js", ['com.cognitect.transit.delimiters'], []);
|
||||
goog.addDependency("../com/cognitect/transit/caching.js", ['com.cognitect.transit.caching'], ['com.cognitect.transit.delimiters']);
|
||||
goog.addDependency("../com/cognitect/transit/impl/decoder.js", ['com.cognitect.transit.impl.decoder'], ['com.cognitect.transit.util', 'com.cognitect.transit.delimiters', 'com.cognitect.transit.caching', 'com.cognitect.transit.types']);
|
||||
goog.addDependency("../com/cognitect/transit/impl/reader.js", ['com.cognitect.transit.impl.reader'], ['com.cognitect.transit.impl.decoder', 'com.cognitect.transit.caching']);
|
||||
goog.addDependency("../com/cognitect/transit/handlers.js", ['com.cognitect.transit.handlers'], ['com.cognitect.transit.util', 'com.cognitect.transit.types', 'goog.math.Long']);
|
||||
goog.addDependency("../com/cognitect/transit/impl/writer.js", ['com.cognitect.transit.impl.writer'], ['com.cognitect.transit.util', 'com.cognitect.transit.caching', 'com.cognitect.transit.handlers', 'com.cognitect.transit.types', 'com.cognitect.transit.delimiters', 'goog.math.Long']);
|
||||
goog.addDependency("../com/cognitect/transit.js", ['com.cognitect.transit'], ['com.cognitect.transit.util', 'com.cognitect.transit.impl.reader', 'com.cognitect.transit.impl.writer', 'com.cognitect.transit.types', 'com.cognitect.transit.eq', 'com.cognitect.transit.impl.decoder', 'com.cognitect.transit.caching']);
|
||||
goog.addDependency("../cognitect/transit.js", ['cognitect.transit'], ['com.cognitect.transit.eq', 'cljs.core', 'com.cognitect.transit.types', 'com.cognitect.transit', 'goog.math.Long']);
|
||||
goog.addDependency("../cljs_http/util.js", ['cljs_http.util'], ['no.en.core', 'goog.Uri', 'cljs.core', 'goog.userAgent', 'cognitect.transit', 'clojure.string']);
|
||||
goog.addDependency("../cljs/core/async/impl/protocols.js", ['cljs.core.async.impl.protocols'], ['cljs.core']);
|
||||
goog.addDependency("../cljs/core/async/impl/buffers.js", ['cljs.core.async.impl.buffers'], ['cljs.core', 'cljs.core.async.impl.protocols']);
|
||||
goog.addDependency("../cljs/core/async/impl/dispatch.js", ['cljs.core.async.impl.dispatch'], ['cljs.core', 'cljs.core.async.impl.buffers', 'goog.async.nextTick']);
|
||||
goog.addDependency("../cljs/core/async/impl/channels.js", ['cljs.core.async.impl.channels'], ['cljs.core.async.impl.dispatch', 'cljs.core', 'cljs.core.async.impl.buffers', 'cljs.core.async.impl.protocols']);
|
||||
goog.addDependency("../cljs/core/async/impl/ioc_helpers.js", ['cljs.core.async.impl.ioc_helpers'], ['cljs.core', 'cljs.core.async.impl.protocols']);
|
||||
goog.addDependency("../cljs/core/async/impl/timers.js", ['cljs.core.async.impl.timers'], ['cljs.core.async.impl.channels', 'cljs.core.async.impl.dispatch', 'cljs.core', 'cljs.core.async.impl.protocols']);
|
||||
goog.addDependency("../cljs/core/async.js", ['cljs.core.async'], ['cljs.core.async.impl.channels', 'cljs.core.async.impl.dispatch', 'cljs.core', 'cljs.core.async.impl.buffers', 'cljs.core.async.impl.protocols', 'cljs.core.async.impl.ioc_helpers', 'goog.array', 'cljs.core.async.impl.timers']);
|
||||
goog.addDependency("../cljs_http/core.js", ['cljs_http.core'], ['goog.net.Jsonp', 'goog.net.XhrIo', 'cljs.core', 'cljs_http.util', 'cljs.core.async', 'goog.net.EventType', 'clojure.string', 'goog.net.ErrorCode']);
|
||||
goog.addDependency("../cljs_http/client.js", ['cljs_http.client'], ['cljs_http.core', 'no.en.core', 'goog.Uri', 'cljs.core', 'cljs_http.util', 'cljs.core.async', 'clojure.string', 'cljs.reader']);
|
||||
goog.addDependency("../geocsv_lite/gis.js", ['geocsv_lite.gis'], ['cljs.core', 'geocsv_lite.notify', 'clojure.string', 'cljs.reader']);
|
||||
goog.addDependency("../geocsv_lite/data.js", ['geocsv_lite.data'], ['cljs.core', 'cljs_http.client', 'clojure.browser.dom', 'cljs.core.async', 'geocsv_lite.map', 'geocsv_lite.notify', 'clojure.string', 'geocsv_lite.gis']);
|
||||
goog.addDependency("../geocsv_lite/core.js", ['geocsv_lite.core'], ['cljs.core', 'clojure.browser.dom', 'geocsv_lite.map', 'geocsv_lite.data', 'geocsv_lite.notify', 'clojure.string']);
|
||||
|
|
@ -0,0 +1,369 @@
|
|||
(ns cljs-http.client
|
||||
(:refer-clojure :exclude [get])
|
||||
(:require [cljs-http.core :as core]
|
||||
[cljs-http.util :as util]
|
||||
[cljs.core.async :as async :refer [<! chan close! put!]]
|
||||
[cljs.reader :refer [read-string]]
|
||||
[clojure.string :refer [blank? join split]]
|
||||
[goog.Uri :as uri]
|
||||
[no.en.core :refer [url-encode url-decode]])
|
||||
(:require-macros [cljs.core.async.macros :refer [go]]))
|
||||
|
||||
(defn if-pos [v]
|
||||
(if (and v (pos? v)) v))
|
||||
|
||||
(defn- acc-param [o v]
|
||||
(cond
|
||||
(coll? o) (conj o v)
|
||||
(some? o) [o v]
|
||||
:else v))
|
||||
|
||||
(defn parse-query-params
|
||||
"Parse `s` as query params and return a hash map."
|
||||
[s]
|
||||
(if-not (blank? s)
|
||||
(reduce
|
||||
#(let [[k v] (split %2 #"=")]
|
||||
(update %1
|
||||
(keyword (url-decode k))
|
||||
acc-param
|
||||
(url-decode v)))
|
||||
{} (split (str s) #"&"))))
|
||||
|
||||
(defn parse-url
|
||||
"Parse `url` into a hash map."
|
||||
[url]
|
||||
(if-not (blank? url)
|
||||
(let [uri (uri/parse url)
|
||||
query-data (.getQueryData uri)]
|
||||
{:scheme (keyword (.getScheme uri))
|
||||
:server-name (.getDomain uri)
|
||||
:server-port (if-pos (.getPort uri))
|
||||
:uri (.getPath uri)
|
||||
:query-string (if-not (.isEmpty query-data)
|
||||
(str query-data))
|
||||
:query-params (if-not (.isEmpty query-data)
|
||||
(parse-query-params (str query-data)))})))
|
||||
|
||||
(def unexceptional-status?
|
||||
#{200 201 202 203 204 205 206 207 300 301 302 303 307})
|
||||
|
||||
(defn- encode-val [k v]
|
||||
(str (url-encode (name k)) "=" (url-encode (str v))))
|
||||
|
||||
(defn- encode-vals [k vs]
|
||||
(->>
|
||||
vs
|
||||
(map #(encode-val k %))
|
||||
(join "&")))
|
||||
|
||||
(defn- encode-param [[k v]]
|
||||
(if (coll? v)
|
||||
(encode-vals k v)
|
||||
(encode-val k v)))
|
||||
|
||||
(defn generate-query-string [params]
|
||||
(->>
|
||||
params
|
||||
(map encode-param)
|
||||
(join "&")))
|
||||
|
||||
(def regex-char-esc-smap
|
||||
(let [esc-chars "()*&^%$#!+"]
|
||||
(zipmap esc-chars
|
||||
(map #(str "\\" %) esc-chars))))
|
||||
|
||||
(defn escape-special
|
||||
"Escape special characters -- for content-type."
|
||||
[string]
|
||||
(->> string
|
||||
(replace regex-char-esc-smap)
|
||||
(reduce str)))
|
||||
|
||||
(defn decode-body
|
||||
"Decocde the :body of `response` with `decode-fn` if the content type matches."
|
||||
[response decode-fn content-type request-method]
|
||||
(if (and (not= :head request-method)
|
||||
(not= 204 (:status response))
|
||||
(re-find (re-pattern (str "(?i)" (escape-special content-type)))
|
||||
(str (clojure.core/get (:headers response) "content-type" ""))))
|
||||
(update-in response [:body] decode-fn)
|
||||
response))
|
||||
|
||||
(defn wrap-edn-params
|
||||
"Encode :edn-params in the `request` :body and set the appropriate
|
||||
Content Type header."
|
||||
[client]
|
||||
(fn [request]
|
||||
(if-let [params (:edn-params request)]
|
||||
(let [headers (merge {"content-type" "application/edn"} (:headers request))]
|
||||
(-> (dissoc request :edn-params)
|
||||
(assoc :body (pr-str params))
|
||||
(assoc :headers headers)
|
||||
(client)))
|
||||
(client request))))
|
||||
|
||||
(defn wrap-edn-response
|
||||
"Decode application/edn responses."
|
||||
[client]
|
||||
(fn [request]
|
||||
(-> #(decode-body % read-string "application/edn" (:request-method request))
|
||||
(async/map [(client request)]))))
|
||||
|
||||
(defn wrap-default-headers
|
||||
[client & [default-headers]]
|
||||
(fn [request]
|
||||
(if-let [default-headers (or (:default-headers request) default-headers)]
|
||||
(client (assoc request :default-headers default-headers))
|
||||
(client request))))
|
||||
|
||||
(defn wrap-accept
|
||||
[client & [accept]]
|
||||
(fn [request]
|
||||
(if-let [accept (or (:accept request) accept)]
|
||||
(client (assoc-in request [:headers "accept"] accept))
|
||||
(client request))))
|
||||
|
||||
(defn wrap-content-type
|
||||
[client & [content-type]]
|
||||
(fn [request]
|
||||
(if-let [content-type (or (:content-type request) content-type)]
|
||||
(client (assoc-in request [:headers "content-type"] content-type))
|
||||
(client request))))
|
||||
|
||||
(def ^{:private true} default-transit-opts
|
||||
{:encoding :json :encoding-opts {}
|
||||
:decoding :json :decoding-opts {}})
|
||||
|
||||
(defn wrap-transit-params
|
||||
"Encode :transit-params in the `request` :body and set the appropriate
|
||||
Content Type header.
|
||||
|
||||
A :transit-opts map can be optionally provided with the following keys:
|
||||
|
||||
:encoding #{:json, :json-verbose}
|
||||
:decoding #{:json, :json-verbose}
|
||||
:encoding/decoding-opts appropriate map of options to be passed to
|
||||
transit writer/reader, respectively."
|
||||
[client]
|
||||
(fn [request]
|
||||
(if-let [params (:transit-params request)]
|
||||
(let [{:keys [encoding encoding-opts]} (merge default-transit-opts
|
||||
(:transit-opts request))
|
||||
headers (merge {"content-type" "application/transit+json"} (:headers request))]
|
||||
(-> (dissoc request :transit-params)
|
||||
(assoc :body (util/transit-encode params encoding encoding-opts))
|
||||
(assoc :headers headers)
|
||||
(client)))
|
||||
(client request))))
|
||||
|
||||
(defn wrap-transit-response
|
||||
"Decode application/transit+json responses."
|
||||
[client]
|
||||
(fn [request]
|
||||
(let [{:keys [decoding decoding-opts]} (merge default-transit-opts
|
||||
(:transit-opts request))
|
||||
transit-decode #(util/transit-decode % decoding decoding-opts)]
|
||||
|
||||
(-> #(decode-body % transit-decode "application/transit+json" (:request-method request))
|
||||
(async/map [(client request)])))))
|
||||
|
||||
(defn wrap-json-params
|
||||
"Encode :json-params in the `request` :body and set the appropriate
|
||||
Content Type header."
|
||||
[client]
|
||||
(fn [request]
|
||||
(if-let [params (:json-params request)]
|
||||
(let [headers (merge {"content-type" "application/json"} (:headers request))]
|
||||
(-> (dissoc request :json-params)
|
||||
(assoc :body (util/json-encode params))
|
||||
(assoc :headers headers)
|
||||
(client)))
|
||||
(client request))))
|
||||
|
||||
(defn wrap-json-response
|
||||
"Decode application/json responses."
|
||||
[client]
|
||||
(fn [request]
|
||||
(-> #(decode-body % util/json-decode "application/json" (:request-method request))
|
||||
(async/map [(client request)]))))
|
||||
|
||||
(defn wrap-query-params [client]
|
||||
(fn [{:keys [query-params] :as req}]
|
||||
(if query-params
|
||||
(client (-> req (dissoc :query-params)
|
||||
(assoc :query-string
|
||||
(generate-query-string query-params))))
|
||||
(client req))))
|
||||
|
||||
(defn wrap-form-params [client]
|
||||
(fn [{:keys [form-params request-method headers] :as request}]
|
||||
(if (and form-params (#{:post :put :patch :delete} request-method))
|
||||
(let [headers (merge {"content-type" "application/x-www-form-urlencoded"} headers)]
|
||||
(client (-> request
|
||||
(dissoc :form-params)
|
||||
(assoc :body (generate-query-string form-params))
|
||||
(assoc :headers headers))))
|
||||
(client request))))
|
||||
|
||||
(defn generate-form-data [params]
|
||||
(let [form-data (js/FormData.)]
|
||||
(doseq [[k v] params]
|
||||
(if (coll? v)
|
||||
(.append form-data (name k) (first v) (second v))
|
||||
(.append form-data (name k) v)))
|
||||
form-data))
|
||||
|
||||
(defn wrap-multipart-params [client]
|
||||
(fn [{:keys [multipart-params request-method] :as request}]
|
||||
(if (and multipart-params (#{:post :put :patch :delete} request-method))
|
||||
(client (-> request
|
||||
(dissoc :multipart-params)
|
||||
(assoc :body (generate-form-data multipart-params))))
|
||||
(client request))))
|
||||
|
||||
(defn wrap-method [client]
|
||||
(fn [req]
|
||||
(if-let [m (:method req)]
|
||||
(client (-> req (dissoc :method)
|
||||
(assoc :request-method m)))
|
||||
(client req))))
|
||||
|
||||
(defn wrap-server-name [client server-name]
|
||||
#(client (assoc %1 :server-name server-name)))
|
||||
|
||||
(defn wrap-url [client]
|
||||
(fn [{:keys [query-params] :as req}]
|
||||
(if-let [spec (parse-url (:url req))]
|
||||
(client (-> (merge req spec)
|
||||
(dissoc :url)
|
||||
(update-in [:query-params] #(merge %1 query-params))))
|
||||
(client req))))
|
||||
|
||||
(defn wrap-basic-auth
|
||||
"Middleware converting the :basic-auth option or `credentials` into
|
||||
an Authorization header."
|
||||
[client & [credentials]]
|
||||
(fn [req]
|
||||
(let [credentials (or (:basic-auth req) credentials)]
|
||||
(if-not (empty? credentials)
|
||||
(client (-> (dissoc req :basic-auth)
|
||||
(assoc-in [:headers "authorization"] (util/basic-auth credentials))))
|
||||
(client req)))))
|
||||
|
||||
(defn wrap-oauth
|
||||
"Middleware converting the :oauth-token option into an Authorization header."
|
||||
[client]
|
||||
(fn [req]
|
||||
(if-let [oauth-token (:oauth-token req)]
|
||||
(client (-> req (dissoc :oauth-token)
|
||||
(assoc-in [:headers "authorization"]
|
||||
(str "Bearer " oauth-token))))
|
||||
(client req))))
|
||||
|
||||
(defn wrap-channel-from-request-map
|
||||
"Pipe the response-channel into the request-map's
|
||||
custom channel (e.g. to enable transducers)"
|
||||
[client]
|
||||
(fn [request]
|
||||
(if-let [custom-channel (:channel request)]
|
||||
(async/pipe (client request) custom-channel)
|
||||
(client request))))
|
||||
|
||||
(defn wrap-request
|
||||
"Returns a batteries-included HTTP request function coresponding to the given
|
||||
core client. See client/request"
|
||||
[request]
|
||||
(-> request
|
||||
wrap-accept
|
||||
wrap-form-params
|
||||
wrap-multipart-params
|
||||
wrap-edn-params
|
||||
wrap-edn-response
|
||||
wrap-transit-params
|
||||
wrap-transit-response
|
||||
wrap-json-params
|
||||
wrap-json-response
|
||||
wrap-content-type
|
||||
wrap-query-params
|
||||
wrap-basic-auth
|
||||
wrap-oauth
|
||||
wrap-method
|
||||
wrap-url
|
||||
wrap-channel-from-request-map
|
||||
wrap-default-headers))
|
||||
|
||||
(def #^{:doc
|
||||
"Executes the HTTP request corresponding to the given map and returns the
|
||||
response map for corresponding to the resulting HTTP response.
|
||||
|
||||
In addition to the standard Ring request keys, the following keys are also
|
||||
recognized:
|
||||
* :url
|
||||
* :method
|
||||
* :query-params"}
|
||||
request (wrap-request core/request))
|
||||
|
||||
(defn delete
|
||||
"Like #'request, but sets the :method and :url as appropriate."
|
||||
[url & [req]]
|
||||
(request (merge req {:method :delete :url url})))
|
||||
|
||||
(defn get
|
||||
"Like #'request, but sets the :method and :url as appropriate."
|
||||
[url & [req]]
|
||||
(request (merge req {:method :get :url url})))
|
||||
|
||||
(defn head
|
||||
"Like #'request, but sets the :method and :url as appropriate."
|
||||
[url & [req]]
|
||||
(request (merge req {:method :head :url url})))
|
||||
|
||||
(defn jsonp
|
||||
"Like #'request, but sets the :method and :url as appropriate."
|
||||
[url & [req]]
|
||||
(request (merge req {:method :jsonp :url url})))
|
||||
|
||||
(defn move
|
||||
"Like #'request, but sets the :method and :url as appropriate."
|
||||
[url & [req]]
|
||||
(request (merge req {:method :move :url url})))
|
||||
|
||||
(defn options
|
||||
"Like #'request, but sets the :method and :url as appropriate."
|
||||
[url & [req]]
|
||||
(request (merge req {:method :options :url url})))
|
||||
|
||||
(defn patch
|
||||
"Like #'request, but sets the :method and :url as appropriate."
|
||||
[url & [req]]
|
||||
(request (merge req {:method :patch :url url})))
|
||||
|
||||
(defn post
|
||||
"Like #'request, but sets the :method and :url as appropriate."
|
||||
[url & [req]]
|
||||
(request (merge req {:method :post :url url})))
|
||||
|
||||
(defn put
|
||||
"Like #'request, but sets the :method and :url as appropriate."
|
||||
[url & [req]]
|
||||
(request (merge req {:method :put :url url})))
|
||||
|
||||
(comment
|
||||
|
||||
(ns example.core
|
||||
(:require [cljs-http.client :as http]
|
||||
[cljs.core.async :refer [<!]])
|
||||
(:require-macros [cljs.core.async.macros :refer [go]]))
|
||||
|
||||
(go (prn (map :login (:body (<! (get "https://api.github.com/users"))))))
|
||||
|
||||
(go (prn (:status (<! (get "http://api.burningswell.dev/continents")))))
|
||||
|
||||
(go (prn (map :name (:body (<! (get "http://api.burningswell.dev/continents"))))))
|
||||
|
||||
(go (let [response (<! (get "https://api.github.com/users"))]
|
||||
(prn (:status response))
|
||||
(prn (map :login (:body response)))))
|
||||
|
||||
(go (prn (<! (get "http://api.burningswell.dev/continents")))))
|
||||
File diff suppressed because one or more lines are too long
991
resources/public/target/cljsbuild-compiler-1/cljs_http/client.js
Normal file
991
resources/public/target/cljsbuild-compiler-1/cljs_http/client.js
Normal file
|
|
@ -0,0 +1,991 @@
|
|||
// Compiled by ClojureScript 1.10.520 {}
|
||||
goog.provide('cljs_http.client');
|
||||
goog.require('cljs.core');
|
||||
goog.require('cljs_http.core');
|
||||
goog.require('cljs_http.util');
|
||||
goog.require('cljs.core.async');
|
||||
goog.require('cljs.reader');
|
||||
goog.require('clojure.string');
|
||||
goog.require('goog.Uri');
|
||||
goog.require('no.en.core');
|
||||
cljs_http.client.if_pos = (function cljs_http$client$if_pos(v){
|
||||
if(cljs.core.truth_((function (){var and__4120__auto__ = v;
|
||||
if(cljs.core.truth_(and__4120__auto__)){
|
||||
return (v > (0));
|
||||
} else {
|
||||
return and__4120__auto__;
|
||||
}
|
||||
})())){
|
||||
return v;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
cljs_http.client.acc_param = (function cljs_http$client$acc_param(o,v){
|
||||
if(cljs.core.coll_QMARK_.call(null,o)){
|
||||
return cljs.core.conj.call(null,o,v);
|
||||
} else {
|
||||
if((!((o == null)))){
|
||||
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [o,v], null);
|
||||
} else {
|
||||
return v;
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
/**
|
||||
* Parse `s` as query params and return a hash map.
|
||||
*/
|
||||
cljs_http.client.parse_query_params = (function cljs_http$client$parse_query_params(s){
|
||||
if((!(clojure.string.blank_QMARK_.call(null,s)))){
|
||||
return cljs.core.reduce.call(null,(function (p1__25690_SHARP_,p2__25689_SHARP_){
|
||||
var vec__25691 = clojure.string.split.call(null,p2__25689_SHARP_,/=/);
|
||||
var k = cljs.core.nth.call(null,vec__25691,(0),null);
|
||||
var v = cljs.core.nth.call(null,vec__25691,(1),null);
|
||||
return cljs.core.update.call(null,p1__25690_SHARP_,cljs.core.keyword.call(null,no.en.core.url_decode.call(null,k)),cljs_http.client.acc_param,no.en.core.url_decode.call(null,v));
|
||||
}),cljs.core.PersistentArrayMap.EMPTY,clojure.string.split.call(null,cljs.core.str.cljs$core$IFn$_invoke$arity$1(s),/&/));
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
/**
|
||||
* Parse `url` into a hash map.
|
||||
*/
|
||||
cljs_http.client.parse_url = (function cljs_http$client$parse_url(url){
|
||||
if((!(clojure.string.blank_QMARK_.call(null,url)))){
|
||||
var uri = goog.Uri.parse(url);
|
||||
var query_data = uri.getQueryData();
|
||||
return new cljs.core.PersistentArrayMap(null, 6, [new cljs.core.Keyword(null,"scheme","scheme",90199613),cljs.core.keyword.call(null,uri.getScheme()),new cljs.core.Keyword(null,"server-name","server-name",-1012104295),uri.getDomain(),new cljs.core.Keyword(null,"server-port","server-port",663745648),cljs_http.client.if_pos.call(null,uri.getPort()),new cljs.core.Keyword(null,"uri","uri",-774711847),uri.getPath(),new cljs.core.Keyword(null,"query-string","query-string",-1018845061),((cljs.core.not.call(null,query_data.isEmpty()))?cljs.core.str.cljs$core$IFn$_invoke$arity$1(query_data):null),new cljs.core.Keyword(null,"query-params","query-params",900640534),((cljs.core.not.call(null,query_data.isEmpty()))?cljs_http.client.parse_query_params.call(null,cljs.core.str.cljs$core$IFn$_invoke$arity$1(query_data)):null)], null);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
cljs_http.client.unexceptional_status_QMARK_ = new cljs.core.PersistentHashSet(null, new cljs.core.PersistentArrayMap(null, 13, [(205),null,(206),null,(300),null,(204),null,(307),null,(303),null,(301),null,(201),null,(302),null,(202),null,(200),null,(203),null,(207),null], null), null);
|
||||
cljs_http.client.encode_val = (function cljs_http$client$encode_val(k,v){
|
||||
return [cljs.core.str.cljs$core$IFn$_invoke$arity$1(no.en.core.url_encode.call(null,cljs.core.name.call(null,k))),"=",cljs.core.str.cljs$core$IFn$_invoke$arity$1(no.en.core.url_encode.call(null,cljs.core.str.cljs$core$IFn$_invoke$arity$1(v)))].join('');
|
||||
});
|
||||
cljs_http.client.encode_vals = (function cljs_http$client$encode_vals(k,vs){
|
||||
return clojure.string.join.call(null,"&",cljs.core.map.call(null,(function (p1__25694_SHARP_){
|
||||
return cljs_http.client.encode_val.call(null,k,p1__25694_SHARP_);
|
||||
}),vs));
|
||||
});
|
||||
cljs_http.client.encode_param = (function cljs_http$client$encode_param(p__25695){
|
||||
var vec__25696 = p__25695;
|
||||
var k = cljs.core.nth.call(null,vec__25696,(0),null);
|
||||
var v = cljs.core.nth.call(null,vec__25696,(1),null);
|
||||
if(cljs.core.coll_QMARK_.call(null,v)){
|
||||
return cljs_http.client.encode_vals.call(null,k,v);
|
||||
} else {
|
||||
return cljs_http.client.encode_val.call(null,k,v);
|
||||
}
|
||||
});
|
||||
cljs_http.client.generate_query_string = (function cljs_http$client$generate_query_string(params){
|
||||
return clojure.string.join.call(null,"&",cljs.core.map.call(null,cljs_http.client.encode_param,params));
|
||||
});
|
||||
cljs_http.client.regex_char_esc_smap = (function (){var esc_chars = "()*&^%$#!+";
|
||||
return cljs.core.zipmap.call(null,esc_chars,cljs.core.map.call(null,((function (esc_chars){
|
||||
return (function (p1__25699_SHARP_){
|
||||
return ["\\",cljs.core.str.cljs$core$IFn$_invoke$arity$1(p1__25699_SHARP_)].join('');
|
||||
});})(esc_chars))
|
||||
,esc_chars));
|
||||
})();
|
||||
/**
|
||||
* Escape special characters -- for content-type.
|
||||
*/
|
||||
cljs_http.client.escape_special = (function cljs_http$client$escape_special(string){
|
||||
return cljs.core.reduce.call(null,cljs.core.str,cljs.core.replace.call(null,cljs_http.client.regex_char_esc_smap,string));
|
||||
});
|
||||
/**
|
||||
* Decocde the :body of `response` with `decode-fn` if the content type matches.
|
||||
*/
|
||||
cljs_http.client.decode_body = (function cljs_http$client$decode_body(response,decode_fn,content_type,request_method){
|
||||
if(cljs.core.truth_((function (){var and__4120__auto__ = cljs.core.not_EQ_.call(null,new cljs.core.Keyword(null,"head","head",-771383919),request_method);
|
||||
if(and__4120__auto__){
|
||||
var and__4120__auto____$1 = cljs.core.not_EQ_.call(null,(204),new cljs.core.Keyword(null,"status","status",-1997798413).cljs$core$IFn$_invoke$arity$1(response));
|
||||
if(and__4120__auto____$1){
|
||||
return cljs.core.re_find.call(null,cljs.core.re_pattern.call(null,["(?i)",cljs.core.str.cljs$core$IFn$_invoke$arity$1(cljs_http.client.escape_special.call(null,content_type))].join('')),cljs.core.str.cljs$core$IFn$_invoke$arity$1(cljs.core.get.call(null,new cljs.core.Keyword(null,"headers","headers",-835030129).cljs$core$IFn$_invoke$arity$1(response),"content-type","")));
|
||||
} else {
|
||||
return and__4120__auto____$1;
|
||||
}
|
||||
} else {
|
||||
return and__4120__auto__;
|
||||
}
|
||||
})())){
|
||||
return cljs.core.update_in.call(null,response,new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"body","body",-2049205669)], null),decode_fn);
|
||||
} else {
|
||||
return response;
|
||||
}
|
||||
});
|
||||
/**
|
||||
* Encode :edn-params in the `request` :body and set the appropriate
|
||||
* Content Type header.
|
||||
*/
|
||||
cljs_http.client.wrap_edn_params = (function cljs_http$client$wrap_edn_params(client){
|
||||
return (function (request){
|
||||
var temp__5718__auto__ = new cljs.core.Keyword(null,"edn-params","edn-params",894273052).cljs$core$IFn$_invoke$arity$1(request);
|
||||
if(cljs.core.truth_(temp__5718__auto__)){
|
||||
var params = temp__5718__auto__;
|
||||
var headers = cljs.core.merge.call(null,new cljs.core.PersistentArrayMap(null, 1, ["content-type","application/edn"], null),new cljs.core.Keyword(null,"headers","headers",-835030129).cljs$core$IFn$_invoke$arity$1(request));
|
||||
return client.call(null,cljs.core.assoc.call(null,cljs.core.assoc.call(null,cljs.core.dissoc.call(null,request,new cljs.core.Keyword(null,"edn-params","edn-params",894273052)),new cljs.core.Keyword(null,"body","body",-2049205669),cljs.core.pr_str.call(null,params)),new cljs.core.Keyword(null,"headers","headers",-835030129),headers));
|
||||
} else {
|
||||
return client.call(null,request);
|
||||
}
|
||||
});
|
||||
});
|
||||
/**
|
||||
* Decode application/edn responses.
|
||||
*/
|
||||
cljs_http.client.wrap_edn_response = (function cljs_http$client$wrap_edn_response(client){
|
||||
return (function (request){
|
||||
return cljs.core.async.map.call(null,(function (p1__25700_SHARP_){
|
||||
return cljs_http.client.decode_body.call(null,p1__25700_SHARP_,cljs.reader.read_string,"application/edn",new cljs.core.Keyword(null,"request-method","request-method",1764796830).cljs$core$IFn$_invoke$arity$1(request));
|
||||
}),new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, [client.call(null,request)], null));
|
||||
});
|
||||
});
|
||||
cljs_http.client.wrap_default_headers = (function cljs_http$client$wrap_default_headers(var_args){
|
||||
var args__4736__auto__ = [];
|
||||
var len__4730__auto___25707 = arguments.length;
|
||||
var i__4731__auto___25708 = (0);
|
||||
while(true){
|
||||
if((i__4731__auto___25708 < len__4730__auto___25707)){
|
||||
args__4736__auto__.push((arguments[i__4731__auto___25708]));
|
||||
|
||||
var G__25709 = (i__4731__auto___25708 + (1));
|
||||
i__4731__auto___25708 = G__25709;
|
||||
continue;
|
||||
} else {
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
var argseq__4737__auto__ = ((((1) < args__4736__auto__.length))?(new cljs.core.IndexedSeq(args__4736__auto__.slice((1)),(0),null)):null);
|
||||
return cljs_http.client.wrap_default_headers.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),argseq__4737__auto__);
|
||||
});
|
||||
|
||||
cljs_http.client.wrap_default_headers.cljs$core$IFn$_invoke$arity$variadic = (function (client,p__25703){
|
||||
var vec__25704 = p__25703;
|
||||
var default_headers = cljs.core.nth.call(null,vec__25704,(0),null);
|
||||
return ((function (vec__25704,default_headers){
|
||||
return (function (request){
|
||||
var temp__5718__auto__ = (function (){var or__4131__auto__ = new cljs.core.Keyword(null,"default-headers","default-headers",-43146094).cljs$core$IFn$_invoke$arity$1(request);
|
||||
if(cljs.core.truth_(or__4131__auto__)){
|
||||
return or__4131__auto__;
|
||||
} else {
|
||||
return default_headers;
|
||||
}
|
||||
})();
|
||||
if(cljs.core.truth_(temp__5718__auto__)){
|
||||
var default_headers__$1 = temp__5718__auto__;
|
||||
return client.call(null,cljs.core.assoc.call(null,request,new cljs.core.Keyword(null,"default-headers","default-headers",-43146094),default_headers__$1));
|
||||
} else {
|
||||
return client.call(null,request);
|
||||
}
|
||||
});
|
||||
;})(vec__25704,default_headers))
|
||||
});
|
||||
|
||||
cljs_http.client.wrap_default_headers.cljs$lang$maxFixedArity = (1);
|
||||
|
||||
/** @this {Function} */
|
||||
cljs_http.client.wrap_default_headers.cljs$lang$applyTo = (function (seq25701){
|
||||
var G__25702 = cljs.core.first.call(null,seq25701);
|
||||
var seq25701__$1 = cljs.core.next.call(null,seq25701);
|
||||
var self__4717__auto__ = this;
|
||||
return self__4717__auto__.cljs$core$IFn$_invoke$arity$variadic(G__25702,seq25701__$1);
|
||||
});
|
||||
|
||||
cljs_http.client.wrap_accept = (function cljs_http$client$wrap_accept(var_args){
|
||||
var args__4736__auto__ = [];
|
||||
var len__4730__auto___25716 = arguments.length;
|
||||
var i__4731__auto___25717 = (0);
|
||||
while(true){
|
||||
if((i__4731__auto___25717 < len__4730__auto___25716)){
|
||||
args__4736__auto__.push((arguments[i__4731__auto___25717]));
|
||||
|
||||
var G__25718 = (i__4731__auto___25717 + (1));
|
||||
i__4731__auto___25717 = G__25718;
|
||||
continue;
|
||||
} else {
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
var argseq__4737__auto__ = ((((1) < args__4736__auto__.length))?(new cljs.core.IndexedSeq(args__4736__auto__.slice((1)),(0),null)):null);
|
||||
return cljs_http.client.wrap_accept.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),argseq__4737__auto__);
|
||||
});
|
||||
|
||||
cljs_http.client.wrap_accept.cljs$core$IFn$_invoke$arity$variadic = (function (client,p__25712){
|
||||
var vec__25713 = p__25712;
|
||||
var accept = cljs.core.nth.call(null,vec__25713,(0),null);
|
||||
return ((function (vec__25713,accept){
|
||||
return (function (request){
|
||||
var temp__5718__auto__ = (function (){var or__4131__auto__ = new cljs.core.Keyword(null,"accept","accept",1874130431).cljs$core$IFn$_invoke$arity$1(request);
|
||||
if(cljs.core.truth_(or__4131__auto__)){
|
||||
return or__4131__auto__;
|
||||
} else {
|
||||
return accept;
|
||||
}
|
||||
})();
|
||||
if(cljs.core.truth_(temp__5718__auto__)){
|
||||
var accept__$1 = temp__5718__auto__;
|
||||
return client.call(null,cljs.core.assoc_in.call(null,request,new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"headers","headers",-835030129),"accept"], null),accept__$1));
|
||||
} else {
|
||||
return client.call(null,request);
|
||||
}
|
||||
});
|
||||
;})(vec__25713,accept))
|
||||
});
|
||||
|
||||
cljs_http.client.wrap_accept.cljs$lang$maxFixedArity = (1);
|
||||
|
||||
/** @this {Function} */
|
||||
cljs_http.client.wrap_accept.cljs$lang$applyTo = (function (seq25710){
|
||||
var G__25711 = cljs.core.first.call(null,seq25710);
|
||||
var seq25710__$1 = cljs.core.next.call(null,seq25710);
|
||||
var self__4717__auto__ = this;
|
||||
return self__4717__auto__.cljs$core$IFn$_invoke$arity$variadic(G__25711,seq25710__$1);
|
||||
});
|
||||
|
||||
cljs_http.client.wrap_content_type = (function cljs_http$client$wrap_content_type(var_args){
|
||||
var args__4736__auto__ = [];
|
||||
var len__4730__auto___25725 = arguments.length;
|
||||
var i__4731__auto___25726 = (0);
|
||||
while(true){
|
||||
if((i__4731__auto___25726 < len__4730__auto___25725)){
|
||||
args__4736__auto__.push((arguments[i__4731__auto___25726]));
|
||||
|
||||
var G__25727 = (i__4731__auto___25726 + (1));
|
||||
i__4731__auto___25726 = G__25727;
|
||||
continue;
|
||||
} else {
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
var argseq__4737__auto__ = ((((1) < args__4736__auto__.length))?(new cljs.core.IndexedSeq(args__4736__auto__.slice((1)),(0),null)):null);
|
||||
return cljs_http.client.wrap_content_type.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),argseq__4737__auto__);
|
||||
});
|
||||
|
||||
cljs_http.client.wrap_content_type.cljs$core$IFn$_invoke$arity$variadic = (function (client,p__25721){
|
||||
var vec__25722 = p__25721;
|
||||
var content_type = cljs.core.nth.call(null,vec__25722,(0),null);
|
||||
return ((function (vec__25722,content_type){
|
||||
return (function (request){
|
||||
var temp__5718__auto__ = (function (){var or__4131__auto__ = new cljs.core.Keyword(null,"content-type","content-type",-508222634).cljs$core$IFn$_invoke$arity$1(request);
|
||||
if(cljs.core.truth_(or__4131__auto__)){
|
||||
return or__4131__auto__;
|
||||
} else {
|
||||
return content_type;
|
||||
}
|
||||
})();
|
||||
if(cljs.core.truth_(temp__5718__auto__)){
|
||||
var content_type__$1 = temp__5718__auto__;
|
||||
return client.call(null,cljs.core.assoc_in.call(null,request,new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"headers","headers",-835030129),"content-type"], null),content_type__$1));
|
||||
} else {
|
||||
return client.call(null,request);
|
||||
}
|
||||
});
|
||||
;})(vec__25722,content_type))
|
||||
});
|
||||
|
||||
cljs_http.client.wrap_content_type.cljs$lang$maxFixedArity = (1);
|
||||
|
||||
/** @this {Function} */
|
||||
cljs_http.client.wrap_content_type.cljs$lang$applyTo = (function (seq25719){
|
||||
var G__25720 = cljs.core.first.call(null,seq25719);
|
||||
var seq25719__$1 = cljs.core.next.call(null,seq25719);
|
||||
var self__4717__auto__ = this;
|
||||
return self__4717__auto__.cljs$core$IFn$_invoke$arity$variadic(G__25720,seq25719__$1);
|
||||
});
|
||||
|
||||
cljs_http.client.default_transit_opts = new cljs.core.PersistentArrayMap(null, 4, [new cljs.core.Keyword(null,"encoding","encoding",1728578272),new cljs.core.Keyword(null,"json","json",1279968570),new cljs.core.Keyword(null,"encoding-opts","encoding-opts",-1805664631),cljs.core.PersistentArrayMap.EMPTY,new cljs.core.Keyword(null,"decoding","decoding",-568180903),new cljs.core.Keyword(null,"json","json",1279968570),new cljs.core.Keyword(null,"decoding-opts","decoding-opts",1050289140),cljs.core.PersistentArrayMap.EMPTY], null);
|
||||
/**
|
||||
* Encode :transit-params in the `request` :body and set the appropriate
|
||||
* Content Type header.
|
||||
*
|
||||
* A :transit-opts map can be optionally provided with the following keys:
|
||||
*
|
||||
* :encoding #{:json, :json-verbose}
|
||||
* :decoding #{:json, :json-verbose}
|
||||
* :encoding/decoding-opts appropriate map of options to be passed to
|
||||
* transit writer/reader, respectively.
|
||||
*/
|
||||
cljs_http.client.wrap_transit_params = (function cljs_http$client$wrap_transit_params(client){
|
||||
return (function (request){
|
||||
var temp__5718__auto__ = new cljs.core.Keyword(null,"transit-params","transit-params",357261095).cljs$core$IFn$_invoke$arity$1(request);
|
||||
if(cljs.core.truth_(temp__5718__auto__)){
|
||||
var params = temp__5718__auto__;
|
||||
var map__25728 = cljs.core.merge.call(null,cljs_http.client.default_transit_opts,new cljs.core.Keyword(null,"transit-opts","transit-opts",1104386010).cljs$core$IFn$_invoke$arity$1(request));
|
||||
var map__25728__$1 = (((((!((map__25728 == null))))?(((((map__25728.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__25728.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__25728):map__25728);
|
||||
var encoding = cljs.core.get.call(null,map__25728__$1,new cljs.core.Keyword(null,"encoding","encoding",1728578272));
|
||||
var encoding_opts = cljs.core.get.call(null,map__25728__$1,new cljs.core.Keyword(null,"encoding-opts","encoding-opts",-1805664631));
|
||||
var headers = cljs.core.merge.call(null,new cljs.core.PersistentArrayMap(null, 1, ["content-type","application/transit+json"], null),new cljs.core.Keyword(null,"headers","headers",-835030129).cljs$core$IFn$_invoke$arity$1(request));
|
||||
return client.call(null,cljs.core.assoc.call(null,cljs.core.assoc.call(null,cljs.core.dissoc.call(null,request,new cljs.core.Keyword(null,"transit-params","transit-params",357261095)),new cljs.core.Keyword(null,"body","body",-2049205669),cljs_http.util.transit_encode.call(null,params,encoding,encoding_opts)),new cljs.core.Keyword(null,"headers","headers",-835030129),headers));
|
||||
} else {
|
||||
return client.call(null,request);
|
||||
}
|
||||
});
|
||||
});
|
||||
/**
|
||||
* Decode application/transit+json responses.
|
||||
*/
|
||||
cljs_http.client.wrap_transit_response = (function cljs_http$client$wrap_transit_response(client){
|
||||
return (function (request){
|
||||
var map__25732 = cljs.core.merge.call(null,cljs_http.client.default_transit_opts,new cljs.core.Keyword(null,"transit-opts","transit-opts",1104386010).cljs$core$IFn$_invoke$arity$1(request));
|
||||
var map__25732__$1 = (((((!((map__25732 == null))))?(((((map__25732.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__25732.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__25732):map__25732);
|
||||
var decoding = cljs.core.get.call(null,map__25732__$1,new cljs.core.Keyword(null,"decoding","decoding",-568180903));
|
||||
var decoding_opts = cljs.core.get.call(null,map__25732__$1,new cljs.core.Keyword(null,"decoding-opts","decoding-opts",1050289140));
|
||||
var transit_decode = ((function (map__25732,map__25732__$1,decoding,decoding_opts){
|
||||
return (function (p1__25730_SHARP_){
|
||||
return cljs_http.util.transit_decode.call(null,p1__25730_SHARP_,decoding,decoding_opts);
|
||||
});})(map__25732,map__25732__$1,decoding,decoding_opts))
|
||||
;
|
||||
return cljs.core.async.map.call(null,((function (map__25732,map__25732__$1,decoding,decoding_opts,transit_decode){
|
||||
return (function (p1__25731_SHARP_){
|
||||
return cljs_http.client.decode_body.call(null,p1__25731_SHARP_,transit_decode,"application/transit+json",new cljs.core.Keyword(null,"request-method","request-method",1764796830).cljs$core$IFn$_invoke$arity$1(request));
|
||||
});})(map__25732,map__25732__$1,decoding,decoding_opts,transit_decode))
|
||||
,new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, [client.call(null,request)], null));
|
||||
});
|
||||
});
|
||||
/**
|
||||
* Encode :json-params in the `request` :body and set the appropriate
|
||||
* Content Type header.
|
||||
*/
|
||||
cljs_http.client.wrap_json_params = (function cljs_http$client$wrap_json_params(client){
|
||||
return (function (request){
|
||||
var temp__5718__auto__ = new cljs.core.Keyword(null,"json-params","json-params",-1112693596).cljs$core$IFn$_invoke$arity$1(request);
|
||||
if(cljs.core.truth_(temp__5718__auto__)){
|
||||
var params = temp__5718__auto__;
|
||||
var headers = cljs.core.merge.call(null,new cljs.core.PersistentArrayMap(null, 1, ["content-type","application/json"], null),new cljs.core.Keyword(null,"headers","headers",-835030129).cljs$core$IFn$_invoke$arity$1(request));
|
||||
return client.call(null,cljs.core.assoc.call(null,cljs.core.assoc.call(null,cljs.core.dissoc.call(null,request,new cljs.core.Keyword(null,"json-params","json-params",-1112693596)),new cljs.core.Keyword(null,"body","body",-2049205669),cljs_http.util.json_encode.call(null,params)),new cljs.core.Keyword(null,"headers","headers",-835030129),headers));
|
||||
} else {
|
||||
return client.call(null,request);
|
||||
}
|
||||
});
|
||||
});
|
||||
/**
|
||||
* Decode application/json responses.
|
||||
*/
|
||||
cljs_http.client.wrap_json_response = (function cljs_http$client$wrap_json_response(client){
|
||||
return (function (request){
|
||||
return cljs.core.async.map.call(null,(function (p1__25734_SHARP_){
|
||||
return cljs_http.client.decode_body.call(null,p1__25734_SHARP_,cljs_http.util.json_decode,"application/json",new cljs.core.Keyword(null,"request-method","request-method",1764796830).cljs$core$IFn$_invoke$arity$1(request));
|
||||
}),new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, [client.call(null,request)], null));
|
||||
});
|
||||
});
|
||||
cljs_http.client.wrap_query_params = (function cljs_http$client$wrap_query_params(client){
|
||||
return (function (p__25735){
|
||||
var map__25736 = p__25735;
|
||||
var map__25736__$1 = (((((!((map__25736 == null))))?(((((map__25736.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__25736.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__25736):map__25736);
|
||||
var req = map__25736__$1;
|
||||
var query_params = cljs.core.get.call(null,map__25736__$1,new cljs.core.Keyword(null,"query-params","query-params",900640534));
|
||||
if(cljs.core.truth_(query_params)){
|
||||
return client.call(null,cljs.core.assoc.call(null,cljs.core.dissoc.call(null,req,new cljs.core.Keyword(null,"query-params","query-params",900640534)),new cljs.core.Keyword(null,"query-string","query-string",-1018845061),cljs_http.client.generate_query_string.call(null,query_params)));
|
||||
} else {
|
||||
return client.call(null,req);
|
||||
}
|
||||
});
|
||||
});
|
||||
cljs_http.client.wrap_form_params = (function cljs_http$client$wrap_form_params(client){
|
||||
return (function (p__25738){
|
||||
var map__25739 = p__25738;
|
||||
var map__25739__$1 = (((((!((map__25739 == null))))?(((((map__25739.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__25739.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__25739):map__25739);
|
||||
var request = map__25739__$1;
|
||||
var form_params = cljs.core.get.call(null,map__25739__$1,new cljs.core.Keyword(null,"form-params","form-params",1884296467));
|
||||
var request_method = cljs.core.get.call(null,map__25739__$1,new cljs.core.Keyword(null,"request-method","request-method",1764796830));
|
||||
var headers = cljs.core.get.call(null,map__25739__$1,new cljs.core.Keyword(null,"headers","headers",-835030129));
|
||||
if(cljs.core.truth_((function (){var and__4120__auto__ = form_params;
|
||||
if(cljs.core.truth_(and__4120__auto__)){
|
||||
return new cljs.core.PersistentHashSet(null, new cljs.core.PersistentArrayMap(null, 4, [new cljs.core.Keyword(null,"patch","patch",380775109),null,new cljs.core.Keyword(null,"delete","delete",-1768633620),null,new cljs.core.Keyword(null,"post","post",269697687),null,new cljs.core.Keyword(null,"put","put",1299772570),null], null), null).call(null,request_method);
|
||||
} else {
|
||||
return and__4120__auto__;
|
||||
}
|
||||
})())){
|
||||
var headers__$1 = cljs.core.merge.call(null,new cljs.core.PersistentArrayMap(null, 1, ["content-type","application/x-www-form-urlencoded"], null),headers);
|
||||
return client.call(null,cljs.core.assoc.call(null,cljs.core.assoc.call(null,cljs.core.dissoc.call(null,request,new cljs.core.Keyword(null,"form-params","form-params",1884296467)),new cljs.core.Keyword(null,"body","body",-2049205669),cljs_http.client.generate_query_string.call(null,form_params)),new cljs.core.Keyword(null,"headers","headers",-835030129),headers__$1));
|
||||
} else {
|
||||
return client.call(null,request);
|
||||
}
|
||||
});
|
||||
});
|
||||
cljs_http.client.generate_form_data = (function cljs_http$client$generate_form_data(params){
|
||||
var form_data = (new FormData());
|
||||
var seq__25741_25757 = cljs.core.seq.call(null,params);
|
||||
var chunk__25742_25758 = null;
|
||||
var count__25743_25759 = (0);
|
||||
var i__25744_25760 = (0);
|
||||
while(true){
|
||||
if((i__25744_25760 < count__25743_25759)){
|
||||
var vec__25751_25761 = cljs.core._nth.call(null,chunk__25742_25758,i__25744_25760);
|
||||
var k_25762 = cljs.core.nth.call(null,vec__25751_25761,(0),null);
|
||||
var v_25763 = cljs.core.nth.call(null,vec__25751_25761,(1),null);
|
||||
if(cljs.core.coll_QMARK_.call(null,v_25763)){
|
||||
form_data.append(cljs.core.name.call(null,k_25762),cljs.core.first.call(null,v_25763),cljs.core.second.call(null,v_25763));
|
||||
} else {
|
||||
form_data.append(cljs.core.name.call(null,k_25762),v_25763);
|
||||
}
|
||||
|
||||
|
||||
var G__25764 = seq__25741_25757;
|
||||
var G__25765 = chunk__25742_25758;
|
||||
var G__25766 = count__25743_25759;
|
||||
var G__25767 = (i__25744_25760 + (1));
|
||||
seq__25741_25757 = G__25764;
|
||||
chunk__25742_25758 = G__25765;
|
||||
count__25743_25759 = G__25766;
|
||||
i__25744_25760 = G__25767;
|
||||
continue;
|
||||
} else {
|
||||
var temp__5720__auto___25768 = cljs.core.seq.call(null,seq__25741_25757);
|
||||
if(temp__5720__auto___25768){
|
||||
var seq__25741_25769__$1 = temp__5720__auto___25768;
|
||||
if(cljs.core.chunked_seq_QMARK_.call(null,seq__25741_25769__$1)){
|
||||
var c__4550__auto___25770 = cljs.core.chunk_first.call(null,seq__25741_25769__$1);
|
||||
var G__25771 = cljs.core.chunk_rest.call(null,seq__25741_25769__$1);
|
||||
var G__25772 = c__4550__auto___25770;
|
||||
var G__25773 = cljs.core.count.call(null,c__4550__auto___25770);
|
||||
var G__25774 = (0);
|
||||
seq__25741_25757 = G__25771;
|
||||
chunk__25742_25758 = G__25772;
|
||||
count__25743_25759 = G__25773;
|
||||
i__25744_25760 = G__25774;
|
||||
continue;
|
||||
} else {
|
||||
var vec__25754_25775 = cljs.core.first.call(null,seq__25741_25769__$1);
|
||||
var k_25776 = cljs.core.nth.call(null,vec__25754_25775,(0),null);
|
||||
var v_25777 = cljs.core.nth.call(null,vec__25754_25775,(1),null);
|
||||
if(cljs.core.coll_QMARK_.call(null,v_25777)){
|
||||
form_data.append(cljs.core.name.call(null,k_25776),cljs.core.first.call(null,v_25777),cljs.core.second.call(null,v_25777));
|
||||
} else {
|
||||
form_data.append(cljs.core.name.call(null,k_25776),v_25777);
|
||||
}
|
||||
|
||||
|
||||
var G__25778 = cljs.core.next.call(null,seq__25741_25769__$1);
|
||||
var G__25779 = null;
|
||||
var G__25780 = (0);
|
||||
var G__25781 = (0);
|
||||
seq__25741_25757 = G__25778;
|
||||
chunk__25742_25758 = G__25779;
|
||||
count__25743_25759 = G__25780;
|
||||
i__25744_25760 = G__25781;
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return form_data;
|
||||
});
|
||||
cljs_http.client.wrap_multipart_params = (function cljs_http$client$wrap_multipart_params(client){
|
||||
return (function (p__25782){
|
||||
var map__25783 = p__25782;
|
||||
var map__25783__$1 = (((((!((map__25783 == null))))?(((((map__25783.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__25783.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__25783):map__25783);
|
||||
var request = map__25783__$1;
|
||||
var multipart_params = cljs.core.get.call(null,map__25783__$1,new cljs.core.Keyword(null,"multipart-params","multipart-params",-1033508707));
|
||||
var request_method = cljs.core.get.call(null,map__25783__$1,new cljs.core.Keyword(null,"request-method","request-method",1764796830));
|
||||
if(cljs.core.truth_((function (){var and__4120__auto__ = multipart_params;
|
||||
if(cljs.core.truth_(and__4120__auto__)){
|
||||
return new cljs.core.PersistentHashSet(null, new cljs.core.PersistentArrayMap(null, 4, [new cljs.core.Keyword(null,"patch","patch",380775109),null,new cljs.core.Keyword(null,"delete","delete",-1768633620),null,new cljs.core.Keyword(null,"post","post",269697687),null,new cljs.core.Keyword(null,"put","put",1299772570),null], null), null).call(null,request_method);
|
||||
} else {
|
||||
return and__4120__auto__;
|
||||
}
|
||||
})())){
|
||||
return client.call(null,cljs.core.assoc.call(null,cljs.core.dissoc.call(null,request,new cljs.core.Keyword(null,"multipart-params","multipart-params",-1033508707)),new cljs.core.Keyword(null,"body","body",-2049205669),cljs_http.client.generate_form_data.call(null,multipart_params)));
|
||||
} else {
|
||||
return client.call(null,request);
|
||||
}
|
||||
});
|
||||
});
|
||||
cljs_http.client.wrap_method = (function cljs_http$client$wrap_method(client){
|
||||
return (function (req){
|
||||
var temp__5718__auto__ = new cljs.core.Keyword(null,"method","method",55703592).cljs$core$IFn$_invoke$arity$1(req);
|
||||
if(cljs.core.truth_(temp__5718__auto__)){
|
||||
var m = temp__5718__auto__;
|
||||
return client.call(null,cljs.core.assoc.call(null,cljs.core.dissoc.call(null,req,new cljs.core.Keyword(null,"method","method",55703592)),new cljs.core.Keyword(null,"request-method","request-method",1764796830),m));
|
||||
} else {
|
||||
return client.call(null,req);
|
||||
}
|
||||
});
|
||||
});
|
||||
cljs_http.client.wrap_server_name = (function cljs_http$client$wrap_server_name(client,server_name){
|
||||
return (function (p1__25785_SHARP_){
|
||||
return client.call(null,cljs.core.assoc.call(null,p1__25785_SHARP_,new cljs.core.Keyword(null,"server-name","server-name",-1012104295),server_name));
|
||||
});
|
||||
});
|
||||
cljs_http.client.wrap_url = (function cljs_http$client$wrap_url(client){
|
||||
return (function (p__25787){
|
||||
var map__25788 = p__25787;
|
||||
var map__25788__$1 = (((((!((map__25788 == null))))?(((((map__25788.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__25788.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__25788):map__25788);
|
||||
var req = map__25788__$1;
|
||||
var query_params = cljs.core.get.call(null,map__25788__$1,new cljs.core.Keyword(null,"query-params","query-params",900640534));
|
||||
var temp__5718__auto__ = cljs_http.client.parse_url.call(null,new cljs.core.Keyword(null,"url","url",276297046).cljs$core$IFn$_invoke$arity$1(req));
|
||||
if(cljs.core.truth_(temp__5718__auto__)){
|
||||
var spec = temp__5718__auto__;
|
||||
return client.call(null,cljs.core.update_in.call(null,cljs.core.dissoc.call(null,cljs.core.merge.call(null,req,spec),new cljs.core.Keyword(null,"url","url",276297046)),new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"query-params","query-params",900640534)], null),((function (spec,temp__5718__auto__,map__25788,map__25788__$1,req,query_params){
|
||||
return (function (p1__25786_SHARP_){
|
||||
return cljs.core.merge.call(null,p1__25786_SHARP_,query_params);
|
||||
});})(spec,temp__5718__auto__,map__25788,map__25788__$1,req,query_params))
|
||||
));
|
||||
} else {
|
||||
return client.call(null,req);
|
||||
}
|
||||
});
|
||||
});
|
||||
/**
|
||||
* Middleware converting the :basic-auth option or `credentials` into
|
||||
* an Authorization header.
|
||||
*/
|
||||
cljs_http.client.wrap_basic_auth = (function cljs_http$client$wrap_basic_auth(var_args){
|
||||
var args__4736__auto__ = [];
|
||||
var len__4730__auto___25796 = arguments.length;
|
||||
var i__4731__auto___25797 = (0);
|
||||
while(true){
|
||||
if((i__4731__auto___25797 < len__4730__auto___25796)){
|
||||
args__4736__auto__.push((arguments[i__4731__auto___25797]));
|
||||
|
||||
var G__25798 = (i__4731__auto___25797 + (1));
|
||||
i__4731__auto___25797 = G__25798;
|
||||
continue;
|
||||
} else {
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
var argseq__4737__auto__ = ((((1) < args__4736__auto__.length))?(new cljs.core.IndexedSeq(args__4736__auto__.slice((1)),(0),null)):null);
|
||||
return cljs_http.client.wrap_basic_auth.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),argseq__4737__auto__);
|
||||
});
|
||||
|
||||
cljs_http.client.wrap_basic_auth.cljs$core$IFn$_invoke$arity$variadic = (function (client,p__25792){
|
||||
var vec__25793 = p__25792;
|
||||
var credentials = cljs.core.nth.call(null,vec__25793,(0),null);
|
||||
return ((function (vec__25793,credentials){
|
||||
return (function (req){
|
||||
var credentials__$1 = (function (){var or__4131__auto__ = new cljs.core.Keyword(null,"basic-auth","basic-auth",-673163332).cljs$core$IFn$_invoke$arity$1(req);
|
||||
if(cljs.core.truth_(or__4131__auto__)){
|
||||
return or__4131__auto__;
|
||||
} else {
|
||||
return credentials;
|
||||
}
|
||||
})();
|
||||
if((!(cljs.core.empty_QMARK_.call(null,credentials__$1)))){
|
||||
return client.call(null,cljs.core.assoc_in.call(null,cljs.core.dissoc.call(null,req,new cljs.core.Keyword(null,"basic-auth","basic-auth",-673163332)),new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"headers","headers",-835030129),"authorization"], null),cljs_http.util.basic_auth.call(null,credentials__$1)));
|
||||
} else {
|
||||
return client.call(null,req);
|
||||
}
|
||||
});
|
||||
;})(vec__25793,credentials))
|
||||
});
|
||||
|
||||
cljs_http.client.wrap_basic_auth.cljs$lang$maxFixedArity = (1);
|
||||
|
||||
/** @this {Function} */
|
||||
cljs_http.client.wrap_basic_auth.cljs$lang$applyTo = (function (seq25790){
|
||||
var G__25791 = cljs.core.first.call(null,seq25790);
|
||||
var seq25790__$1 = cljs.core.next.call(null,seq25790);
|
||||
var self__4717__auto__ = this;
|
||||
return self__4717__auto__.cljs$core$IFn$_invoke$arity$variadic(G__25791,seq25790__$1);
|
||||
});
|
||||
|
||||
/**
|
||||
* Middleware converting the :oauth-token option into an Authorization header.
|
||||
*/
|
||||
cljs_http.client.wrap_oauth = (function cljs_http$client$wrap_oauth(client){
|
||||
return (function (req){
|
||||
var temp__5718__auto__ = new cljs.core.Keyword(null,"oauth-token","oauth-token",311415191).cljs$core$IFn$_invoke$arity$1(req);
|
||||
if(cljs.core.truth_(temp__5718__auto__)){
|
||||
var oauth_token = temp__5718__auto__;
|
||||
return client.call(null,cljs.core.assoc_in.call(null,cljs.core.dissoc.call(null,req,new cljs.core.Keyword(null,"oauth-token","oauth-token",311415191)),new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"headers","headers",-835030129),"authorization"], null),["Bearer ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(oauth_token)].join('')));
|
||||
} else {
|
||||
return client.call(null,req);
|
||||
}
|
||||
});
|
||||
});
|
||||
/**
|
||||
* Pipe the response-channel into the request-map's
|
||||
* custom channel (e.g. to enable transducers)
|
||||
*/
|
||||
cljs_http.client.wrap_channel_from_request_map = (function cljs_http$client$wrap_channel_from_request_map(client){
|
||||
return (function (request){
|
||||
var temp__5718__auto__ = new cljs.core.Keyword(null,"channel","channel",734187692).cljs$core$IFn$_invoke$arity$1(request);
|
||||
if(cljs.core.truth_(temp__5718__auto__)){
|
||||
var custom_channel = temp__5718__auto__;
|
||||
return cljs.core.async.pipe.call(null,client.call(null,request),custom_channel);
|
||||
} else {
|
||||
return client.call(null,request);
|
||||
}
|
||||
});
|
||||
});
|
||||
/**
|
||||
* Returns a batteries-included HTTP request function coresponding to the given
|
||||
* core client. See client/request
|
||||
*/
|
||||
cljs_http.client.wrap_request = (function cljs_http$client$wrap_request(request){
|
||||
return cljs_http.client.wrap_default_headers.call(null,cljs_http.client.wrap_channel_from_request_map.call(null,cljs_http.client.wrap_url.call(null,cljs_http.client.wrap_method.call(null,cljs_http.client.wrap_oauth.call(null,cljs_http.client.wrap_basic_auth.call(null,cljs_http.client.wrap_query_params.call(null,cljs_http.client.wrap_content_type.call(null,cljs_http.client.wrap_json_response.call(null,cljs_http.client.wrap_json_params.call(null,cljs_http.client.wrap_transit_response.call(null,cljs_http.client.wrap_transit_params.call(null,cljs_http.client.wrap_edn_response.call(null,cljs_http.client.wrap_edn_params.call(null,cljs_http.client.wrap_multipart_params.call(null,cljs_http.client.wrap_form_params.call(null,cljs_http.client.wrap_accept.call(null,request)))))))))))))))));
|
||||
});
|
||||
/**
|
||||
* Executes the HTTP request corresponding to the given map and returns the
|
||||
* response map for corresponding to the resulting HTTP response.
|
||||
*
|
||||
* In addition to the standard Ring request keys, the following keys are also
|
||||
* recognized:
|
||||
* * :url
|
||||
* * :method
|
||||
* * :query-params
|
||||
*/
|
||||
cljs_http.client.request = cljs_http.client.wrap_request.call(null,cljs_http.core.request);
|
||||
/**
|
||||
* Like #'request, but sets the :method and :url as appropriate.
|
||||
*/
|
||||
cljs_http.client.delete$ = (function cljs_http$client$delete(var_args){
|
||||
var args__4736__auto__ = [];
|
||||
var len__4730__auto___25805 = arguments.length;
|
||||
var i__4731__auto___25806 = (0);
|
||||
while(true){
|
||||
if((i__4731__auto___25806 < len__4730__auto___25805)){
|
||||
args__4736__auto__.push((arguments[i__4731__auto___25806]));
|
||||
|
||||
var G__25807 = (i__4731__auto___25806 + (1));
|
||||
i__4731__auto___25806 = G__25807;
|
||||
continue;
|
||||
} else {
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
var argseq__4737__auto__ = ((((1) < args__4736__auto__.length))?(new cljs.core.IndexedSeq(args__4736__auto__.slice((1)),(0),null)):null);
|
||||
return cljs_http.client.delete$.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),argseq__4737__auto__);
|
||||
});
|
||||
|
||||
cljs_http.client.delete$.cljs$core$IFn$_invoke$arity$variadic = (function (url,p__25801){
|
||||
var vec__25802 = p__25801;
|
||||
var req = cljs.core.nth.call(null,vec__25802,(0),null);
|
||||
return cljs_http.client.request.call(null,cljs.core.merge.call(null,req,new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"method","method",55703592),new cljs.core.Keyword(null,"delete","delete",-1768633620),new cljs.core.Keyword(null,"url","url",276297046),url], null)));
|
||||
});
|
||||
|
||||
cljs_http.client.delete$.cljs$lang$maxFixedArity = (1);
|
||||
|
||||
/** @this {Function} */
|
||||
cljs_http.client.delete$.cljs$lang$applyTo = (function (seq25799){
|
||||
var G__25800 = cljs.core.first.call(null,seq25799);
|
||||
var seq25799__$1 = cljs.core.next.call(null,seq25799);
|
||||
var self__4717__auto__ = this;
|
||||
return self__4717__auto__.cljs$core$IFn$_invoke$arity$variadic(G__25800,seq25799__$1);
|
||||
});
|
||||
|
||||
/**
|
||||
* Like #'request, but sets the :method and :url as appropriate.
|
||||
*/
|
||||
cljs_http.client.get = (function cljs_http$client$get(var_args){
|
||||
var args__4736__auto__ = [];
|
||||
var len__4730__auto___25814 = arguments.length;
|
||||
var i__4731__auto___25815 = (0);
|
||||
while(true){
|
||||
if((i__4731__auto___25815 < len__4730__auto___25814)){
|
||||
args__4736__auto__.push((arguments[i__4731__auto___25815]));
|
||||
|
||||
var G__25816 = (i__4731__auto___25815 + (1));
|
||||
i__4731__auto___25815 = G__25816;
|
||||
continue;
|
||||
} else {
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
var argseq__4737__auto__ = ((((1) < args__4736__auto__.length))?(new cljs.core.IndexedSeq(args__4736__auto__.slice((1)),(0),null)):null);
|
||||
return cljs_http.client.get.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),argseq__4737__auto__);
|
||||
});
|
||||
|
||||
cljs_http.client.get.cljs$core$IFn$_invoke$arity$variadic = (function (url,p__25810){
|
||||
var vec__25811 = p__25810;
|
||||
var req = cljs.core.nth.call(null,vec__25811,(0),null);
|
||||
return cljs_http.client.request.call(null,cljs.core.merge.call(null,req,new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"method","method",55703592),new cljs.core.Keyword(null,"get","get",1683182755),new cljs.core.Keyword(null,"url","url",276297046),url], null)));
|
||||
});
|
||||
|
||||
cljs_http.client.get.cljs$lang$maxFixedArity = (1);
|
||||
|
||||
/** @this {Function} */
|
||||
cljs_http.client.get.cljs$lang$applyTo = (function (seq25808){
|
||||
var G__25809 = cljs.core.first.call(null,seq25808);
|
||||
var seq25808__$1 = cljs.core.next.call(null,seq25808);
|
||||
var self__4717__auto__ = this;
|
||||
return self__4717__auto__.cljs$core$IFn$_invoke$arity$variadic(G__25809,seq25808__$1);
|
||||
});
|
||||
|
||||
/**
|
||||
* Like #'request, but sets the :method and :url as appropriate.
|
||||
*/
|
||||
cljs_http.client.head = (function cljs_http$client$head(var_args){
|
||||
var args__4736__auto__ = [];
|
||||
var len__4730__auto___25823 = arguments.length;
|
||||
var i__4731__auto___25824 = (0);
|
||||
while(true){
|
||||
if((i__4731__auto___25824 < len__4730__auto___25823)){
|
||||
args__4736__auto__.push((arguments[i__4731__auto___25824]));
|
||||
|
||||
var G__25825 = (i__4731__auto___25824 + (1));
|
||||
i__4731__auto___25824 = G__25825;
|
||||
continue;
|
||||
} else {
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
var argseq__4737__auto__ = ((((1) < args__4736__auto__.length))?(new cljs.core.IndexedSeq(args__4736__auto__.slice((1)),(0),null)):null);
|
||||
return cljs_http.client.head.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),argseq__4737__auto__);
|
||||
});
|
||||
|
||||
cljs_http.client.head.cljs$core$IFn$_invoke$arity$variadic = (function (url,p__25819){
|
||||
var vec__25820 = p__25819;
|
||||
var req = cljs.core.nth.call(null,vec__25820,(0),null);
|
||||
return cljs_http.client.request.call(null,cljs.core.merge.call(null,req,new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"method","method",55703592),new cljs.core.Keyword(null,"head","head",-771383919),new cljs.core.Keyword(null,"url","url",276297046),url], null)));
|
||||
});
|
||||
|
||||
cljs_http.client.head.cljs$lang$maxFixedArity = (1);
|
||||
|
||||
/** @this {Function} */
|
||||
cljs_http.client.head.cljs$lang$applyTo = (function (seq25817){
|
||||
var G__25818 = cljs.core.first.call(null,seq25817);
|
||||
var seq25817__$1 = cljs.core.next.call(null,seq25817);
|
||||
var self__4717__auto__ = this;
|
||||
return self__4717__auto__.cljs$core$IFn$_invoke$arity$variadic(G__25818,seq25817__$1);
|
||||
});
|
||||
|
||||
/**
|
||||
* Like #'request, but sets the :method and :url as appropriate.
|
||||
*/
|
||||
cljs_http.client.jsonp = (function cljs_http$client$jsonp(var_args){
|
||||
var args__4736__auto__ = [];
|
||||
var len__4730__auto___25832 = arguments.length;
|
||||
var i__4731__auto___25833 = (0);
|
||||
while(true){
|
||||
if((i__4731__auto___25833 < len__4730__auto___25832)){
|
||||
args__4736__auto__.push((arguments[i__4731__auto___25833]));
|
||||
|
||||
var G__25834 = (i__4731__auto___25833 + (1));
|
||||
i__4731__auto___25833 = G__25834;
|
||||
continue;
|
||||
} else {
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
var argseq__4737__auto__ = ((((1) < args__4736__auto__.length))?(new cljs.core.IndexedSeq(args__4736__auto__.slice((1)),(0),null)):null);
|
||||
return cljs_http.client.jsonp.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),argseq__4737__auto__);
|
||||
});
|
||||
|
||||
cljs_http.client.jsonp.cljs$core$IFn$_invoke$arity$variadic = (function (url,p__25828){
|
||||
var vec__25829 = p__25828;
|
||||
var req = cljs.core.nth.call(null,vec__25829,(0),null);
|
||||
return cljs_http.client.request.call(null,cljs.core.merge.call(null,req,new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"method","method",55703592),new cljs.core.Keyword(null,"jsonp","jsonp",226119588),new cljs.core.Keyword(null,"url","url",276297046),url], null)));
|
||||
});
|
||||
|
||||
cljs_http.client.jsonp.cljs$lang$maxFixedArity = (1);
|
||||
|
||||
/** @this {Function} */
|
||||
cljs_http.client.jsonp.cljs$lang$applyTo = (function (seq25826){
|
||||
var G__25827 = cljs.core.first.call(null,seq25826);
|
||||
var seq25826__$1 = cljs.core.next.call(null,seq25826);
|
||||
var self__4717__auto__ = this;
|
||||
return self__4717__auto__.cljs$core$IFn$_invoke$arity$variadic(G__25827,seq25826__$1);
|
||||
});
|
||||
|
||||
/**
|
||||
* Like #'request, but sets the :method and :url as appropriate.
|
||||
*/
|
||||
cljs_http.client.move = (function cljs_http$client$move(var_args){
|
||||
var args__4736__auto__ = [];
|
||||
var len__4730__auto___25841 = arguments.length;
|
||||
var i__4731__auto___25842 = (0);
|
||||
while(true){
|
||||
if((i__4731__auto___25842 < len__4730__auto___25841)){
|
||||
args__4736__auto__.push((arguments[i__4731__auto___25842]));
|
||||
|
||||
var G__25843 = (i__4731__auto___25842 + (1));
|
||||
i__4731__auto___25842 = G__25843;
|
||||
continue;
|
||||
} else {
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
var argseq__4737__auto__ = ((((1) < args__4736__auto__.length))?(new cljs.core.IndexedSeq(args__4736__auto__.slice((1)),(0),null)):null);
|
||||
return cljs_http.client.move.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),argseq__4737__auto__);
|
||||
});
|
||||
|
||||
cljs_http.client.move.cljs$core$IFn$_invoke$arity$variadic = (function (url,p__25837){
|
||||
var vec__25838 = p__25837;
|
||||
var req = cljs.core.nth.call(null,vec__25838,(0),null);
|
||||
return cljs_http.client.request.call(null,cljs.core.merge.call(null,req,new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"method","method",55703592),new cljs.core.Keyword(null,"move","move",-2110884309),new cljs.core.Keyword(null,"url","url",276297046),url], null)));
|
||||
});
|
||||
|
||||
cljs_http.client.move.cljs$lang$maxFixedArity = (1);
|
||||
|
||||
/** @this {Function} */
|
||||
cljs_http.client.move.cljs$lang$applyTo = (function (seq25835){
|
||||
var G__25836 = cljs.core.first.call(null,seq25835);
|
||||
var seq25835__$1 = cljs.core.next.call(null,seq25835);
|
||||
var self__4717__auto__ = this;
|
||||
return self__4717__auto__.cljs$core$IFn$_invoke$arity$variadic(G__25836,seq25835__$1);
|
||||
});
|
||||
|
||||
/**
|
||||
* Like #'request, but sets the :method and :url as appropriate.
|
||||
*/
|
||||
cljs_http.client.options = (function cljs_http$client$options(var_args){
|
||||
var args__4736__auto__ = [];
|
||||
var len__4730__auto___25850 = arguments.length;
|
||||
var i__4731__auto___25851 = (0);
|
||||
while(true){
|
||||
if((i__4731__auto___25851 < len__4730__auto___25850)){
|
||||
args__4736__auto__.push((arguments[i__4731__auto___25851]));
|
||||
|
||||
var G__25852 = (i__4731__auto___25851 + (1));
|
||||
i__4731__auto___25851 = G__25852;
|
||||
continue;
|
||||
} else {
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
var argseq__4737__auto__ = ((((1) < args__4736__auto__.length))?(new cljs.core.IndexedSeq(args__4736__auto__.slice((1)),(0),null)):null);
|
||||
return cljs_http.client.options.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),argseq__4737__auto__);
|
||||
});
|
||||
|
||||
cljs_http.client.options.cljs$core$IFn$_invoke$arity$variadic = (function (url,p__25846){
|
||||
var vec__25847 = p__25846;
|
||||
var req = cljs.core.nth.call(null,vec__25847,(0),null);
|
||||
return cljs_http.client.request.call(null,cljs.core.merge.call(null,req,new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"method","method",55703592),new cljs.core.Keyword(null,"options","options",99638489),new cljs.core.Keyword(null,"url","url",276297046),url], null)));
|
||||
});
|
||||
|
||||
cljs_http.client.options.cljs$lang$maxFixedArity = (1);
|
||||
|
||||
/** @this {Function} */
|
||||
cljs_http.client.options.cljs$lang$applyTo = (function (seq25844){
|
||||
var G__25845 = cljs.core.first.call(null,seq25844);
|
||||
var seq25844__$1 = cljs.core.next.call(null,seq25844);
|
||||
var self__4717__auto__ = this;
|
||||
return self__4717__auto__.cljs$core$IFn$_invoke$arity$variadic(G__25845,seq25844__$1);
|
||||
});
|
||||
|
||||
/**
|
||||
* Like #'request, but sets the :method and :url as appropriate.
|
||||
*/
|
||||
cljs_http.client.patch = (function cljs_http$client$patch(var_args){
|
||||
var args__4736__auto__ = [];
|
||||
var len__4730__auto___25859 = arguments.length;
|
||||
var i__4731__auto___25860 = (0);
|
||||
while(true){
|
||||
if((i__4731__auto___25860 < len__4730__auto___25859)){
|
||||
args__4736__auto__.push((arguments[i__4731__auto___25860]));
|
||||
|
||||
var G__25861 = (i__4731__auto___25860 + (1));
|
||||
i__4731__auto___25860 = G__25861;
|
||||
continue;
|
||||
} else {
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
var argseq__4737__auto__ = ((((1) < args__4736__auto__.length))?(new cljs.core.IndexedSeq(args__4736__auto__.slice((1)),(0),null)):null);
|
||||
return cljs_http.client.patch.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),argseq__4737__auto__);
|
||||
});
|
||||
|
||||
cljs_http.client.patch.cljs$core$IFn$_invoke$arity$variadic = (function (url,p__25855){
|
||||
var vec__25856 = p__25855;
|
||||
var req = cljs.core.nth.call(null,vec__25856,(0),null);
|
||||
return cljs_http.client.request.call(null,cljs.core.merge.call(null,req,new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"method","method",55703592),new cljs.core.Keyword(null,"patch","patch",380775109),new cljs.core.Keyword(null,"url","url",276297046),url], null)));
|
||||
});
|
||||
|
||||
cljs_http.client.patch.cljs$lang$maxFixedArity = (1);
|
||||
|
||||
/** @this {Function} */
|
||||
cljs_http.client.patch.cljs$lang$applyTo = (function (seq25853){
|
||||
var G__25854 = cljs.core.first.call(null,seq25853);
|
||||
var seq25853__$1 = cljs.core.next.call(null,seq25853);
|
||||
var self__4717__auto__ = this;
|
||||
return self__4717__auto__.cljs$core$IFn$_invoke$arity$variadic(G__25854,seq25853__$1);
|
||||
});
|
||||
|
||||
/**
|
||||
* Like #'request, but sets the :method and :url as appropriate.
|
||||
*/
|
||||
cljs_http.client.post = (function cljs_http$client$post(var_args){
|
||||
var args__4736__auto__ = [];
|
||||
var len__4730__auto___25868 = arguments.length;
|
||||
var i__4731__auto___25869 = (0);
|
||||
while(true){
|
||||
if((i__4731__auto___25869 < len__4730__auto___25868)){
|
||||
args__4736__auto__.push((arguments[i__4731__auto___25869]));
|
||||
|
||||
var G__25870 = (i__4731__auto___25869 + (1));
|
||||
i__4731__auto___25869 = G__25870;
|
||||
continue;
|
||||
} else {
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
var argseq__4737__auto__ = ((((1) < args__4736__auto__.length))?(new cljs.core.IndexedSeq(args__4736__auto__.slice((1)),(0),null)):null);
|
||||
return cljs_http.client.post.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),argseq__4737__auto__);
|
||||
});
|
||||
|
||||
cljs_http.client.post.cljs$core$IFn$_invoke$arity$variadic = (function (url,p__25864){
|
||||
var vec__25865 = p__25864;
|
||||
var req = cljs.core.nth.call(null,vec__25865,(0),null);
|
||||
return cljs_http.client.request.call(null,cljs.core.merge.call(null,req,new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"method","method",55703592),new cljs.core.Keyword(null,"post","post",269697687),new cljs.core.Keyword(null,"url","url",276297046),url], null)));
|
||||
});
|
||||
|
||||
cljs_http.client.post.cljs$lang$maxFixedArity = (1);
|
||||
|
||||
/** @this {Function} */
|
||||
cljs_http.client.post.cljs$lang$applyTo = (function (seq25862){
|
||||
var G__25863 = cljs.core.first.call(null,seq25862);
|
||||
var seq25862__$1 = cljs.core.next.call(null,seq25862);
|
||||
var self__4717__auto__ = this;
|
||||
return self__4717__auto__.cljs$core$IFn$_invoke$arity$variadic(G__25863,seq25862__$1);
|
||||
});
|
||||
|
||||
/**
|
||||
* Like #'request, but sets the :method and :url as appropriate.
|
||||
*/
|
||||
cljs_http.client.put = (function cljs_http$client$put(var_args){
|
||||
var args__4736__auto__ = [];
|
||||
var len__4730__auto___25877 = arguments.length;
|
||||
var i__4731__auto___25878 = (0);
|
||||
while(true){
|
||||
if((i__4731__auto___25878 < len__4730__auto___25877)){
|
||||
args__4736__auto__.push((arguments[i__4731__auto___25878]));
|
||||
|
||||
var G__25879 = (i__4731__auto___25878 + (1));
|
||||
i__4731__auto___25878 = G__25879;
|
||||
continue;
|
||||
} else {
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
var argseq__4737__auto__ = ((((1) < args__4736__auto__.length))?(new cljs.core.IndexedSeq(args__4736__auto__.slice((1)),(0),null)):null);
|
||||
return cljs_http.client.put.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),argseq__4737__auto__);
|
||||
});
|
||||
|
||||
cljs_http.client.put.cljs$core$IFn$_invoke$arity$variadic = (function (url,p__25873){
|
||||
var vec__25874 = p__25873;
|
||||
var req = cljs.core.nth.call(null,vec__25874,(0),null);
|
||||
return cljs_http.client.request.call(null,cljs.core.merge.call(null,req,new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"method","method",55703592),new cljs.core.Keyword(null,"put","put",1299772570),new cljs.core.Keyword(null,"url","url",276297046),url], null)));
|
||||
});
|
||||
|
||||
cljs_http.client.put.cljs$lang$maxFixedArity = (1);
|
||||
|
||||
/** @this {Function} */
|
||||
cljs_http.client.put.cljs$lang$applyTo = (function (seq25871){
|
||||
var G__25872 = cljs.core.first.call(null,seq25871);
|
||||
var seq25871__$1 = cljs.core.next.call(null,seq25871);
|
||||
var self__4717__auto__ = this;
|
||||
return self__4717__auto__.cljs$core$IFn$_invoke$arity$variadic(G__25872,seq25871__$1);
|
||||
});
|
||||
|
||||
|
||||
//# sourceMappingURL=client.js.map
|
||||
File diff suppressed because one or more lines are too long
150
resources/public/target/cljsbuild-compiler-1/cljs_http/core.cljs
Normal file
150
resources/public/target/cljsbuild-compiler-1/cljs_http/core.cljs
Normal file
|
|
@ -0,0 +1,150 @@
|
|||
(ns cljs-http.core
|
||||
(:import [goog.net EventType ErrorCode XhrIo]
|
||||
[goog.net Jsonp])
|
||||
(:require-macros [cljs.core.async.macros :refer [go]])
|
||||
(:require [cljs-http.util :as util]
|
||||
[cljs.core.async :as async]
|
||||
[clojure.string :as s]))
|
||||
|
||||
(def pending-requests (atom {}))
|
||||
|
||||
(defn abort!
|
||||
"Attempt to close the given channel and abort the pending HTTP request
|
||||
with which it is associated."
|
||||
[channel]
|
||||
(when-let [req (@pending-requests channel)]
|
||||
(swap! pending-requests dissoc channel)
|
||||
(async/close! channel)
|
||||
(if (.hasOwnProperty req "abort")
|
||||
(.abort req)
|
||||
(.cancel (:jsonp req) (:request req)))))
|
||||
|
||||
(defn- aborted? [xhr]
|
||||
(= (.getLastErrorCode xhr) goog.net.ErrorCode.ABORT))
|
||||
|
||||
(defn apply-default-headers!
|
||||
"Takes an XhrIo object and applies the default-headers to it."
|
||||
[xhr headers]
|
||||
(let [formatted-h (zipmap (map util/camelize (keys headers)) (vals headers))]
|
||||
(dorun
|
||||
(map (fn [[k v]]
|
||||
(.set (.-headers xhr) k v))
|
||||
formatted-h))))
|
||||
|
||||
(defn apply-response-type!
|
||||
"Takes an XhrIo object and sets response-type if not nil."
|
||||
[xhr response-type]
|
||||
(.setResponseType xhr
|
||||
(case response-type
|
||||
:array-buffer XhrIo.ResponseType.ARRAY_BUFFER
|
||||
:blob XhrIo.ResponseType.BLOB
|
||||
:document XhrIo.ResponseType.DOCUMENT
|
||||
:text XhrIo.ResponseType.TEXT
|
||||
:default XhrIo.ResponseType.DEFAULT
|
||||
nil XhrIo.ResponseType.DEFAULT)))
|
||||
|
||||
(defn build-xhr
|
||||
"Builds an XhrIo object from the request parameters."
|
||||
[{:keys [with-credentials? default-headers response-type] :as request}]
|
||||
(let [timeout (or (:timeout request) 0)
|
||||
send-credentials (if (nil? with-credentials?)
|
||||
true
|
||||
with-credentials?)]
|
||||
(doto (XhrIo.)
|
||||
(apply-default-headers! default-headers)
|
||||
(apply-response-type! response-type)
|
||||
(.setTimeoutInterval timeout)
|
||||
(.setWithCredentials send-credentials))))
|
||||
|
||||
;; goog.net.ErrorCode constants to CLJS keywords
|
||||
(def error-kw
|
||||
{0 :no-error
|
||||
1 :access-denied
|
||||
2 :file-not-found
|
||||
3 :ff-silent-error
|
||||
4 :custom-error
|
||||
5 :exception
|
||||
6 :http-error
|
||||
7 :abort
|
||||
8 :timeout
|
||||
9 :offline})
|
||||
|
||||
(defn xhr
|
||||
"Execute the HTTP request corresponding to the given Ring request
|
||||
map and return a core.async channel."
|
||||
[{:keys [request-method headers body with-credentials? cancel progress] :as request}]
|
||||
(let [channel (async/chan)
|
||||
request-url (util/build-url request)
|
||||
method (name (or request-method :get))
|
||||
headers (util/build-headers headers)
|
||||
xhr (build-xhr request)]
|
||||
(swap! pending-requests assoc channel xhr)
|
||||
(.listen xhr EventType.COMPLETE
|
||||
(fn [evt]
|
||||
(let [target (.-target evt)
|
||||
response {:status (.getStatus target)
|
||||
:success (.isSuccess target)
|
||||
:body (.getResponse target)
|
||||
:headers (util/parse-headers (.getAllResponseHeaders target))
|
||||
:trace-redirects [request-url (.getLastUri target)]
|
||||
:error-code (error-kw (.getLastErrorCode target))
|
||||
:error-text (.getLastError target)}]
|
||||
(if-not (aborted? xhr)
|
||||
(async/put! channel response))
|
||||
(swap! pending-requests dissoc channel)
|
||||
(if cancel (async/close! cancel))
|
||||
(async/close! channel))))
|
||||
|
||||
(when progress
|
||||
(let [listener (fn [direction evt]
|
||||
(async/put! progress (merge {:direction direction :loaded (.-loaded evt)}
|
||||
(if (.-lengthComputable evt) {:total (.-total evt)}))))]
|
||||
(doto xhr
|
||||
(.setProgressEventsEnabled true)
|
||||
(.listen EventType.UPLOAD_PROGRESS (partial listener :upload))
|
||||
(.listen EventType.DOWNLOAD_PROGRESS (partial listener :download)))))
|
||||
|
||||
(.send xhr request-url method body headers)
|
||||
(if cancel
|
||||
(go
|
||||
(let [v (async/<! cancel)]
|
||||
(if (not (.isComplete xhr))
|
||||
(.abort xhr)))))
|
||||
channel))
|
||||
|
||||
(defn jsonp
|
||||
"Execute the JSONP request corresponding to the given Ring request
|
||||
map and return a core.async channel."
|
||||
[{:keys [timeout callback-name cancel keywordize-keys?]
|
||||
:or {keywordize-keys? true}
|
||||
:as request}]
|
||||
(let [channel (async/chan)
|
||||
jsonp (Jsonp. (util/build-url request) callback-name)]
|
||||
(.setRequestTimeout jsonp timeout)
|
||||
(let [req (.send jsonp nil
|
||||
(fn success-callback [data]
|
||||
(let [response {:status 200
|
||||
:success true
|
||||
:body (js->clj data :keywordize-keys keywordize-keys?)}]
|
||||
(async/put! channel response)
|
||||
(swap! pending-requests dissoc channel)
|
||||
(if cancel (async/close! cancel))
|
||||
(async/close! channel)))
|
||||
(fn error-callback []
|
||||
(swap! pending-requests dissoc channel)
|
||||
(if cancel (async/close! cancel))
|
||||
(async/close! channel)))]
|
||||
(swap! pending-requests assoc channel {:jsonp jsonp :request req})
|
||||
(if cancel
|
||||
(go
|
||||
(let [v (async/<! cancel)]
|
||||
(.cancel jsonp req)))))
|
||||
channel))
|
||||
|
||||
(defn request
|
||||
"Execute the HTTP request corresponding to the given Ring request
|
||||
map and return a core.async channel."
|
||||
[{:keys [request-method] :as request}]
|
||||
(if (= request-method :jsonp)
|
||||
(jsonp request)
|
||||
(xhr request)))
|
||||
File diff suppressed because one or more lines are too long
480
resources/public/target/cljsbuild-compiler-1/cljs_http/core.js
Normal file
480
resources/public/target/cljsbuild-compiler-1/cljs_http/core.js
Normal file
|
|
@ -0,0 +1,480 @@
|
|||
// Compiled by ClojureScript 1.10.520 {}
|
||||
goog.provide('cljs_http.core');
|
||||
goog.require('cljs.core');
|
||||
goog.require('goog.net.EventType');
|
||||
goog.require('goog.net.ErrorCode');
|
||||
goog.require('goog.net.XhrIo');
|
||||
goog.require('goog.net.Jsonp');
|
||||
goog.require('cljs_http.util');
|
||||
goog.require('cljs.core.async');
|
||||
goog.require('clojure.string');
|
||||
cljs_http.core.pending_requests = cljs.core.atom.call(null,cljs.core.PersistentArrayMap.EMPTY);
|
||||
/**
|
||||
* Attempt to close the given channel and abort the pending HTTP request
|
||||
* with which it is associated.
|
||||
*/
|
||||
cljs_http.core.abort_BANG_ = (function cljs_http$core$abort_BANG_(channel){
|
||||
var temp__5720__auto__ = cljs.core.deref.call(null,cljs_http.core.pending_requests).call(null,channel);
|
||||
if(cljs.core.truth_(temp__5720__auto__)){
|
||||
var req = temp__5720__auto__;
|
||||
cljs.core.swap_BANG_.call(null,cljs_http.core.pending_requests,cljs.core.dissoc,channel);
|
||||
|
||||
cljs.core.async.close_BANG_.call(null,channel);
|
||||
|
||||
if(cljs.core.truth_(req.hasOwnProperty("abort"))){
|
||||
return req.abort();
|
||||
} else {
|
||||
return new cljs.core.Keyword(null,"jsonp","jsonp",226119588).cljs$core$IFn$_invoke$arity$1(req).cancel(new cljs.core.Keyword(null,"request","request",1772954723).cljs$core$IFn$_invoke$arity$1(req));
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
cljs_http.core.aborted_QMARK_ = (function cljs_http$core$aborted_QMARK_(xhr){
|
||||
return cljs.core._EQ_.call(null,xhr.getLastErrorCode(),goog.net.ErrorCode.ABORT);
|
||||
});
|
||||
/**
|
||||
* Takes an XhrIo object and applies the default-headers to it.
|
||||
*/
|
||||
cljs_http.core.apply_default_headers_BANG_ = (function cljs_http$core$apply_default_headers_BANG_(xhr,headers){
|
||||
var formatted_h = cljs.core.zipmap.call(null,cljs.core.map.call(null,cljs_http.util.camelize,cljs.core.keys.call(null,headers)),cljs.core.vals.call(null,headers));
|
||||
return cljs.core.dorun.call(null,cljs.core.map.call(null,((function (formatted_h){
|
||||
return (function (p__25585){
|
||||
var vec__25586 = p__25585;
|
||||
var k = cljs.core.nth.call(null,vec__25586,(0),null);
|
||||
var v = cljs.core.nth.call(null,vec__25586,(1),null);
|
||||
return xhr.headers.set(k,v);
|
||||
});})(formatted_h))
|
||||
,formatted_h));
|
||||
});
|
||||
/**
|
||||
* Takes an XhrIo object and sets response-type if not nil.
|
||||
*/
|
||||
cljs_http.core.apply_response_type_BANG_ = (function cljs_http$core$apply_response_type_BANG_(xhr,response_type){
|
||||
return xhr.setResponseType((function (){var G__25589 = response_type;
|
||||
if(cljs.core._EQ_.call(null,new cljs.core.Keyword(null,"array-buffer","array-buffer",519008380),G__25589)){
|
||||
return goog.net.XhrIo.ResponseType.ARRAY_BUFFER;
|
||||
} else {
|
||||
if(cljs.core._EQ_.call(null,new cljs.core.Keyword(null,"blob","blob",1636965233),G__25589)){
|
||||
return goog.net.XhrIo.ResponseType.BLOB;
|
||||
} else {
|
||||
if(cljs.core._EQ_.call(null,new cljs.core.Keyword(null,"document","document",-1329188687),G__25589)){
|
||||
return goog.net.XhrIo.ResponseType.DOCUMENT;
|
||||
} else {
|
||||
if(cljs.core._EQ_.call(null,new cljs.core.Keyword(null,"text","text",-1790561697),G__25589)){
|
||||
return goog.net.XhrIo.ResponseType.TEXT;
|
||||
} else {
|
||||
if(cljs.core._EQ_.call(null,new cljs.core.Keyword(null,"default","default",-1987822328),G__25589)){
|
||||
return goog.net.XhrIo.ResponseType.DEFAULT;
|
||||
} else {
|
||||
if(cljs.core._EQ_.call(null,null,G__25589)){
|
||||
return goog.net.XhrIo.ResponseType.DEFAULT;
|
||||
} else {
|
||||
throw (new Error(["No matching clause: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(G__25589)].join('')));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})());
|
||||
});
|
||||
/**
|
||||
* Builds an XhrIo object from the request parameters.
|
||||
*/
|
||||
cljs_http.core.build_xhr = (function cljs_http$core$build_xhr(p__25590){
|
||||
var map__25591 = p__25590;
|
||||
var map__25591__$1 = (((((!((map__25591 == null))))?(((((map__25591.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__25591.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__25591):map__25591);
|
||||
var request = map__25591__$1;
|
||||
var with_credentials_QMARK_ = cljs.core.get.call(null,map__25591__$1,new cljs.core.Keyword(null,"with-credentials?","with-credentials?",-1773202222));
|
||||
var default_headers = cljs.core.get.call(null,map__25591__$1,new cljs.core.Keyword(null,"default-headers","default-headers",-43146094));
|
||||
var response_type = cljs.core.get.call(null,map__25591__$1,new cljs.core.Keyword(null,"response-type","response-type",-1493770458));
|
||||
var timeout = (function (){var or__4131__auto__ = new cljs.core.Keyword(null,"timeout","timeout",-318625318).cljs$core$IFn$_invoke$arity$1(request);
|
||||
if(cljs.core.truth_(or__4131__auto__)){
|
||||
return or__4131__auto__;
|
||||
} else {
|
||||
return (0);
|
||||
}
|
||||
})();
|
||||
var send_credentials = (((with_credentials_QMARK_ == null))?true:with_credentials_QMARK_);
|
||||
var G__25593 = (new goog.net.XhrIo());
|
||||
cljs_http.core.apply_default_headers_BANG_.call(null,G__25593,default_headers);
|
||||
|
||||
cljs_http.core.apply_response_type_BANG_.call(null,G__25593,response_type);
|
||||
|
||||
G__25593.setTimeoutInterval(timeout);
|
||||
|
||||
G__25593.setWithCredentials(send_credentials);
|
||||
|
||||
return G__25593;
|
||||
});
|
||||
cljs_http.core.error_kw = cljs.core.PersistentHashMap.fromArrays([(0),(7),(1),(4),(6),(3),(2),(9),(5),(8)],[new cljs.core.Keyword(null,"no-error","no-error",1984610064),new cljs.core.Keyword(null,"abort","abort",521193198),new cljs.core.Keyword(null,"access-denied","access-denied",959449406),new cljs.core.Keyword(null,"custom-error","custom-error",-1565161123),new cljs.core.Keyword(null,"http-error","http-error",-1040049553),new cljs.core.Keyword(null,"ff-silent-error","ff-silent-error",189390514),new cljs.core.Keyword(null,"file-not-found","file-not-found",-65398940),new cljs.core.Keyword(null,"offline","offline",-107631935),new cljs.core.Keyword(null,"exception","exception",-335277064),new cljs.core.Keyword(null,"timeout","timeout",-318625318)]);
|
||||
/**
|
||||
* Execute the HTTP request corresponding to the given Ring request
|
||||
* map and return a core.async channel.
|
||||
*/
|
||||
cljs_http.core.xhr = (function cljs_http$core$xhr(p__25594){
|
||||
var map__25595 = p__25594;
|
||||
var map__25595__$1 = (((((!((map__25595 == null))))?(((((map__25595.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__25595.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__25595):map__25595);
|
||||
var request = map__25595__$1;
|
||||
var request_method = cljs.core.get.call(null,map__25595__$1,new cljs.core.Keyword(null,"request-method","request-method",1764796830));
|
||||
var headers = cljs.core.get.call(null,map__25595__$1,new cljs.core.Keyword(null,"headers","headers",-835030129));
|
||||
var body = cljs.core.get.call(null,map__25595__$1,new cljs.core.Keyword(null,"body","body",-2049205669));
|
||||
var with_credentials_QMARK_ = cljs.core.get.call(null,map__25595__$1,new cljs.core.Keyword(null,"with-credentials?","with-credentials?",-1773202222));
|
||||
var cancel = cljs.core.get.call(null,map__25595__$1,new cljs.core.Keyword(null,"cancel","cancel",-1964088360));
|
||||
var progress = cljs.core.get.call(null,map__25595__$1,new cljs.core.Keyword(null,"progress","progress",244323547));
|
||||
var channel = cljs.core.async.chan.call(null);
|
||||
var request_url = cljs_http.util.build_url.call(null,request);
|
||||
var method = cljs.core.name.call(null,(function (){var or__4131__auto__ = request_method;
|
||||
if(cljs.core.truth_(or__4131__auto__)){
|
||||
return or__4131__auto__;
|
||||
} else {
|
||||
return new cljs.core.Keyword(null,"get","get",1683182755);
|
||||
}
|
||||
})());
|
||||
var headers__$1 = cljs_http.util.build_headers.call(null,headers);
|
||||
var xhr = cljs_http.core.build_xhr.call(null,request);
|
||||
cljs.core.swap_BANG_.call(null,cljs_http.core.pending_requests,cljs.core.assoc,channel,xhr);
|
||||
|
||||
xhr.listen(goog.net.EventType.COMPLETE,((function (channel,request_url,method,headers__$1,xhr,map__25595,map__25595__$1,request,request_method,headers,body,with_credentials_QMARK_,cancel,progress){
|
||||
return (function (evt){
|
||||
var target = evt.target;
|
||||
var response = new cljs.core.PersistentArrayMap(null, 7, [new cljs.core.Keyword(null,"status","status",-1997798413),target.getStatus(),new cljs.core.Keyword(null,"success","success",1890645906),target.isSuccess(),new cljs.core.Keyword(null,"body","body",-2049205669),target.getResponse(),new cljs.core.Keyword(null,"headers","headers",-835030129),cljs_http.util.parse_headers.call(null,target.getAllResponseHeaders()),new cljs.core.Keyword(null,"trace-redirects","trace-redirects",-1149427907),new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [request_url,target.getLastUri()], null),new cljs.core.Keyword(null,"error-code","error-code",180497232),cljs_http.core.error_kw.call(null,target.getLastErrorCode()),new cljs.core.Keyword(null,"error-text","error-text",2021893718),target.getLastError()], null);
|
||||
if((!(cljs_http.core.aborted_QMARK_.call(null,xhr)))){
|
||||
cljs.core.async.put_BANG_.call(null,channel,response);
|
||||
} else {
|
||||
}
|
||||
|
||||
cljs.core.swap_BANG_.call(null,cljs_http.core.pending_requests,cljs.core.dissoc,channel);
|
||||
|
||||
if(cljs.core.truth_(cancel)){
|
||||
cljs.core.async.close_BANG_.call(null,cancel);
|
||||
} else {
|
||||
}
|
||||
|
||||
return cljs.core.async.close_BANG_.call(null,channel);
|
||||
});})(channel,request_url,method,headers__$1,xhr,map__25595,map__25595__$1,request,request_method,headers,body,with_credentials_QMARK_,cancel,progress))
|
||||
);
|
||||
|
||||
if(cljs.core.truth_(progress)){
|
||||
var listener_25619 = ((function (channel,request_url,method,headers__$1,xhr,map__25595,map__25595__$1,request,request_method,headers,body,with_credentials_QMARK_,cancel,progress){
|
||||
return (function (direction,evt){
|
||||
return cljs.core.async.put_BANG_.call(null,progress,cljs.core.merge.call(null,new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"direction","direction",-633359395),direction,new cljs.core.Keyword(null,"loaded","loaded",-1246482293),evt.loaded], null),(cljs.core.truth_(evt.lengthComputable)?new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"total","total",1916810418),evt.total], null):null)));
|
||||
});})(channel,request_url,method,headers__$1,xhr,map__25595,map__25595__$1,request,request_method,headers,body,with_credentials_QMARK_,cancel,progress))
|
||||
;
|
||||
var G__25597_25620 = xhr;
|
||||
G__25597_25620.setProgressEventsEnabled(true);
|
||||
|
||||
G__25597_25620.listen(goog.net.EventType.UPLOAD_PROGRESS,cljs.core.partial.call(null,listener_25619,new cljs.core.Keyword(null,"upload","upload",-255769218)));
|
||||
|
||||
G__25597_25620.listen(goog.net.EventType.DOWNLOAD_PROGRESS,cljs.core.partial.call(null,listener_25619,new cljs.core.Keyword(null,"download","download",-300081668)));
|
||||
|
||||
} else {
|
||||
}
|
||||
|
||||
xhr.send(request_url,method,body,headers__$1);
|
||||
|
||||
if(cljs.core.truth_(cancel)){
|
||||
var c__23644__auto___25621 = cljs.core.async.chan.call(null,(1));
|
||||
cljs.core.async.impl.dispatch.run.call(null,((function (c__23644__auto___25621,channel,request_url,method,headers__$1,xhr,map__25595,map__25595__$1,request,request_method,headers,body,with_credentials_QMARK_,cancel,progress){
|
||||
return (function (){
|
||||
var f__23645__auto__ = (function (){var switch__23549__auto__ = ((function (c__23644__auto___25621,channel,request_url,method,headers__$1,xhr,map__25595,map__25595__$1,request,request_method,headers,body,with_credentials_QMARK_,cancel,progress){
|
||||
return (function (state_25608){
|
||||
var state_val_25609 = (state_25608[(1)]);
|
||||
if((state_val_25609 === (1))){
|
||||
var state_25608__$1 = state_25608;
|
||||
return cljs.core.async.impl.ioc_helpers.take_BANG_.call(null,state_25608__$1,(2),cancel);
|
||||
} else {
|
||||
if((state_val_25609 === (2))){
|
||||
var inst_25599 = (state_25608[(2)]);
|
||||
var inst_25600 = xhr.isComplete();
|
||||
var inst_25601 = cljs.core.not.call(null,inst_25600);
|
||||
var state_25608__$1 = (function (){var statearr_25610 = state_25608;
|
||||
(statearr_25610[(7)] = inst_25599);
|
||||
|
||||
return statearr_25610;
|
||||
})();
|
||||
if(inst_25601){
|
||||
var statearr_25611_25622 = state_25608__$1;
|
||||
(statearr_25611_25622[(1)] = (3));
|
||||
|
||||
} else {
|
||||
var statearr_25612_25623 = state_25608__$1;
|
||||
(statearr_25612_25623[(1)] = (4));
|
||||
|
||||
}
|
||||
|
||||
return new cljs.core.Keyword(null,"recur","recur",-437573268);
|
||||
} else {
|
||||
if((state_val_25609 === (3))){
|
||||
var inst_25603 = xhr.abort();
|
||||
var state_25608__$1 = state_25608;
|
||||
var statearr_25613_25624 = state_25608__$1;
|
||||
(statearr_25613_25624[(2)] = inst_25603);
|
||||
|
||||
(statearr_25613_25624[(1)] = (5));
|
||||
|
||||
|
||||
return new cljs.core.Keyword(null,"recur","recur",-437573268);
|
||||
} else {
|
||||
if((state_val_25609 === (4))){
|
||||
var state_25608__$1 = state_25608;
|
||||
var statearr_25614_25625 = state_25608__$1;
|
||||
(statearr_25614_25625[(2)] = null);
|
||||
|
||||
(statearr_25614_25625[(1)] = (5));
|
||||
|
||||
|
||||
return new cljs.core.Keyword(null,"recur","recur",-437573268);
|
||||
} else {
|
||||
if((state_val_25609 === (5))){
|
||||
var inst_25606 = (state_25608[(2)]);
|
||||
var state_25608__$1 = state_25608;
|
||||
return cljs.core.async.impl.ioc_helpers.return_chan.call(null,state_25608__$1,inst_25606);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});})(c__23644__auto___25621,channel,request_url,method,headers__$1,xhr,map__25595,map__25595__$1,request,request_method,headers,body,with_credentials_QMARK_,cancel,progress))
|
||||
;
|
||||
return ((function (switch__23549__auto__,c__23644__auto___25621,channel,request_url,method,headers__$1,xhr,map__25595,map__25595__$1,request,request_method,headers,body,with_credentials_QMARK_,cancel,progress){
|
||||
return (function() {
|
||||
var cljs_http$core$xhr_$_state_machine__23550__auto__ = null;
|
||||
var cljs_http$core$xhr_$_state_machine__23550__auto____0 = (function (){
|
||||
var statearr_25615 = [null,null,null,null,null,null,null,null];
|
||||
(statearr_25615[(0)] = cljs_http$core$xhr_$_state_machine__23550__auto__);
|
||||
|
||||
(statearr_25615[(1)] = (1));
|
||||
|
||||
return statearr_25615;
|
||||
});
|
||||
var cljs_http$core$xhr_$_state_machine__23550__auto____1 = (function (state_25608){
|
||||
while(true){
|
||||
var ret_value__23551__auto__ = (function (){try{while(true){
|
||||
var result__23552__auto__ = switch__23549__auto__.call(null,state_25608);
|
||||
if(cljs.core.keyword_identical_QMARK_.call(null,result__23552__auto__,new cljs.core.Keyword(null,"recur","recur",-437573268))){
|
||||
continue;
|
||||
} else {
|
||||
return result__23552__auto__;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}catch (e25616){if((e25616 instanceof Object)){
|
||||
var ex__23553__auto__ = e25616;
|
||||
var statearr_25617_25626 = state_25608;
|
||||
(statearr_25617_25626[(5)] = ex__23553__auto__);
|
||||
|
||||
|
||||
cljs.core.async.impl.ioc_helpers.process_exception.call(null,state_25608);
|
||||
|
||||
return new cljs.core.Keyword(null,"recur","recur",-437573268);
|
||||
} else {
|
||||
throw e25616;
|
||||
|
||||
}
|
||||
}})();
|
||||
if(cljs.core.keyword_identical_QMARK_.call(null,ret_value__23551__auto__,new cljs.core.Keyword(null,"recur","recur",-437573268))){
|
||||
var G__25627 = state_25608;
|
||||
state_25608 = G__25627;
|
||||
continue;
|
||||
} else {
|
||||
return ret_value__23551__auto__;
|
||||
}
|
||||
break;
|
||||
}
|
||||
});
|
||||
cljs_http$core$xhr_$_state_machine__23550__auto__ = function(state_25608){
|
||||
switch(arguments.length){
|
||||
case 0:
|
||||
return cljs_http$core$xhr_$_state_machine__23550__auto____0.call(this);
|
||||
case 1:
|
||||
return cljs_http$core$xhr_$_state_machine__23550__auto____1.call(this,state_25608);
|
||||
}
|
||||
throw(new Error('Invalid arity: ' + arguments.length));
|
||||
};
|
||||
cljs_http$core$xhr_$_state_machine__23550__auto__.cljs$core$IFn$_invoke$arity$0 = cljs_http$core$xhr_$_state_machine__23550__auto____0;
|
||||
cljs_http$core$xhr_$_state_machine__23550__auto__.cljs$core$IFn$_invoke$arity$1 = cljs_http$core$xhr_$_state_machine__23550__auto____1;
|
||||
return cljs_http$core$xhr_$_state_machine__23550__auto__;
|
||||
})()
|
||||
;})(switch__23549__auto__,c__23644__auto___25621,channel,request_url,method,headers__$1,xhr,map__25595,map__25595__$1,request,request_method,headers,body,with_credentials_QMARK_,cancel,progress))
|
||||
})();
|
||||
var state__23646__auto__ = (function (){var statearr_25618 = f__23645__auto__.call(null);
|
||||
(statearr_25618[(6)] = c__23644__auto___25621);
|
||||
|
||||
return statearr_25618;
|
||||
})();
|
||||
return cljs.core.async.impl.ioc_helpers.run_state_machine_wrapped.call(null,state__23646__auto__);
|
||||
});})(c__23644__auto___25621,channel,request_url,method,headers__$1,xhr,map__25595,map__25595__$1,request,request_method,headers,body,with_credentials_QMARK_,cancel,progress))
|
||||
);
|
||||
|
||||
} else {
|
||||
}
|
||||
|
||||
return channel;
|
||||
});
|
||||
/**
|
||||
* Execute the JSONP request corresponding to the given Ring request
|
||||
* map and return a core.async channel.
|
||||
*/
|
||||
cljs_http.core.jsonp = (function cljs_http$core$jsonp(p__25628){
|
||||
var map__25629 = p__25628;
|
||||
var map__25629__$1 = (((((!((map__25629 == null))))?(((((map__25629.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__25629.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__25629):map__25629);
|
||||
var request = map__25629__$1;
|
||||
var timeout = cljs.core.get.call(null,map__25629__$1,new cljs.core.Keyword(null,"timeout","timeout",-318625318));
|
||||
var callback_name = cljs.core.get.call(null,map__25629__$1,new cljs.core.Keyword(null,"callback-name","callback-name",336964714));
|
||||
var cancel = cljs.core.get.call(null,map__25629__$1,new cljs.core.Keyword(null,"cancel","cancel",-1964088360));
|
||||
var keywordize_keys_QMARK_ = cljs.core.get.call(null,map__25629__$1,new cljs.core.Keyword(null,"keywordize-keys?","keywordize-keys?",-254545987),true);
|
||||
var channel = cljs.core.async.chan.call(null);
|
||||
var jsonp = (new goog.net.Jsonp(cljs_http.util.build_url.call(null,request),callback_name));
|
||||
jsonp.setRequestTimeout(timeout);
|
||||
|
||||
var req_25642 = jsonp.send(null,((function (channel,jsonp,map__25629,map__25629__$1,request,timeout,callback_name,cancel,keywordize_keys_QMARK_){
|
||||
return (function cljs_http$core$jsonp_$_success_callback(data){
|
||||
var response = new cljs.core.PersistentArrayMap(null, 3, [new cljs.core.Keyword(null,"status","status",-1997798413),(200),new cljs.core.Keyword(null,"success","success",1890645906),true,new cljs.core.Keyword(null,"body","body",-2049205669),cljs.core.js__GT_clj.call(null,data,new cljs.core.Keyword(null,"keywordize-keys","keywordize-keys",1310784252),keywordize_keys_QMARK_)], null);
|
||||
cljs.core.async.put_BANG_.call(null,channel,response);
|
||||
|
||||
cljs.core.swap_BANG_.call(null,cljs_http.core.pending_requests,cljs.core.dissoc,channel);
|
||||
|
||||
if(cljs.core.truth_(cancel)){
|
||||
cljs.core.async.close_BANG_.call(null,cancel);
|
||||
} else {
|
||||
}
|
||||
|
||||
return cljs.core.async.close_BANG_.call(null,channel);
|
||||
});})(channel,jsonp,map__25629,map__25629__$1,request,timeout,callback_name,cancel,keywordize_keys_QMARK_))
|
||||
,((function (channel,jsonp,map__25629,map__25629__$1,request,timeout,callback_name,cancel,keywordize_keys_QMARK_){
|
||||
return (function cljs_http$core$jsonp_$_error_callback(){
|
||||
cljs.core.swap_BANG_.call(null,cljs_http.core.pending_requests,cljs.core.dissoc,channel);
|
||||
|
||||
if(cljs.core.truth_(cancel)){
|
||||
cljs.core.async.close_BANG_.call(null,cancel);
|
||||
} else {
|
||||
}
|
||||
|
||||
return cljs.core.async.close_BANG_.call(null,channel);
|
||||
});})(channel,jsonp,map__25629,map__25629__$1,request,timeout,callback_name,cancel,keywordize_keys_QMARK_))
|
||||
);
|
||||
cljs.core.swap_BANG_.call(null,cljs_http.core.pending_requests,cljs.core.assoc,channel,new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"jsonp","jsonp",226119588),jsonp,new cljs.core.Keyword(null,"request","request",1772954723),req_25642], null));
|
||||
|
||||
if(cljs.core.truth_(cancel)){
|
||||
var c__23644__auto___25643 = cljs.core.async.chan.call(null,(1));
|
||||
cljs.core.async.impl.dispatch.run.call(null,((function (c__23644__auto___25643,req_25642,channel,jsonp,map__25629,map__25629__$1,request,timeout,callback_name,cancel,keywordize_keys_QMARK_){
|
||||
return (function (){
|
||||
var f__23645__auto__ = (function (){var switch__23549__auto__ = ((function (c__23644__auto___25643,req_25642,channel,jsonp,map__25629,map__25629__$1,request,timeout,callback_name,cancel,keywordize_keys_QMARK_){
|
||||
return (function (state_25635){
|
||||
var state_val_25636 = (state_25635[(1)]);
|
||||
if((state_val_25636 === (1))){
|
||||
var state_25635__$1 = state_25635;
|
||||
return cljs.core.async.impl.ioc_helpers.take_BANG_.call(null,state_25635__$1,(2),cancel);
|
||||
} else {
|
||||
if((state_val_25636 === (2))){
|
||||
var inst_25632 = (state_25635[(2)]);
|
||||
var inst_25633 = jsonp.cancel(req_25642);
|
||||
var state_25635__$1 = (function (){var statearr_25637 = state_25635;
|
||||
(statearr_25637[(7)] = inst_25632);
|
||||
|
||||
return statearr_25637;
|
||||
})();
|
||||
return cljs.core.async.impl.ioc_helpers.return_chan.call(null,state_25635__$1,inst_25633);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
});})(c__23644__auto___25643,req_25642,channel,jsonp,map__25629,map__25629__$1,request,timeout,callback_name,cancel,keywordize_keys_QMARK_))
|
||||
;
|
||||
return ((function (switch__23549__auto__,c__23644__auto___25643,req_25642,channel,jsonp,map__25629,map__25629__$1,request,timeout,callback_name,cancel,keywordize_keys_QMARK_){
|
||||
return (function() {
|
||||
var cljs_http$core$jsonp_$_state_machine__23550__auto__ = null;
|
||||
var cljs_http$core$jsonp_$_state_machine__23550__auto____0 = (function (){
|
||||
var statearr_25638 = [null,null,null,null,null,null,null,null];
|
||||
(statearr_25638[(0)] = cljs_http$core$jsonp_$_state_machine__23550__auto__);
|
||||
|
||||
(statearr_25638[(1)] = (1));
|
||||
|
||||
return statearr_25638;
|
||||
});
|
||||
var cljs_http$core$jsonp_$_state_machine__23550__auto____1 = (function (state_25635){
|
||||
while(true){
|
||||
var ret_value__23551__auto__ = (function (){try{while(true){
|
||||
var result__23552__auto__ = switch__23549__auto__.call(null,state_25635);
|
||||
if(cljs.core.keyword_identical_QMARK_.call(null,result__23552__auto__,new cljs.core.Keyword(null,"recur","recur",-437573268))){
|
||||
continue;
|
||||
} else {
|
||||
return result__23552__auto__;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}catch (e25639){if((e25639 instanceof Object)){
|
||||
var ex__23553__auto__ = e25639;
|
||||
var statearr_25640_25644 = state_25635;
|
||||
(statearr_25640_25644[(5)] = ex__23553__auto__);
|
||||
|
||||
|
||||
cljs.core.async.impl.ioc_helpers.process_exception.call(null,state_25635);
|
||||
|
||||
return new cljs.core.Keyword(null,"recur","recur",-437573268);
|
||||
} else {
|
||||
throw e25639;
|
||||
|
||||
}
|
||||
}})();
|
||||
if(cljs.core.keyword_identical_QMARK_.call(null,ret_value__23551__auto__,new cljs.core.Keyword(null,"recur","recur",-437573268))){
|
||||
var G__25645 = state_25635;
|
||||
state_25635 = G__25645;
|
||||
continue;
|
||||
} else {
|
||||
return ret_value__23551__auto__;
|
||||
}
|
||||
break;
|
||||
}
|
||||
});
|
||||
cljs_http$core$jsonp_$_state_machine__23550__auto__ = function(state_25635){
|
||||
switch(arguments.length){
|
||||
case 0:
|
||||
return cljs_http$core$jsonp_$_state_machine__23550__auto____0.call(this);
|
||||
case 1:
|
||||
return cljs_http$core$jsonp_$_state_machine__23550__auto____1.call(this,state_25635);
|
||||
}
|
||||
throw(new Error('Invalid arity: ' + arguments.length));
|
||||
};
|
||||
cljs_http$core$jsonp_$_state_machine__23550__auto__.cljs$core$IFn$_invoke$arity$0 = cljs_http$core$jsonp_$_state_machine__23550__auto____0;
|
||||
cljs_http$core$jsonp_$_state_machine__23550__auto__.cljs$core$IFn$_invoke$arity$1 = cljs_http$core$jsonp_$_state_machine__23550__auto____1;
|
||||
return cljs_http$core$jsonp_$_state_machine__23550__auto__;
|
||||
})()
|
||||
;})(switch__23549__auto__,c__23644__auto___25643,req_25642,channel,jsonp,map__25629,map__25629__$1,request,timeout,callback_name,cancel,keywordize_keys_QMARK_))
|
||||
})();
|
||||
var state__23646__auto__ = (function (){var statearr_25641 = f__23645__auto__.call(null);
|
||||
(statearr_25641[(6)] = c__23644__auto___25643);
|
||||
|
||||
return statearr_25641;
|
||||
})();
|
||||
return cljs.core.async.impl.ioc_helpers.run_state_machine_wrapped.call(null,state__23646__auto__);
|
||||
});})(c__23644__auto___25643,req_25642,channel,jsonp,map__25629,map__25629__$1,request,timeout,callback_name,cancel,keywordize_keys_QMARK_))
|
||||
);
|
||||
|
||||
} else {
|
||||
}
|
||||
|
||||
return channel;
|
||||
});
|
||||
/**
|
||||
* Execute the HTTP request corresponding to the given Ring request
|
||||
* map and return a core.async channel.
|
||||
*/
|
||||
cljs_http.core.request = (function cljs_http$core$request(p__25646){
|
||||
var map__25647 = p__25646;
|
||||
var map__25647__$1 = (((((!((map__25647 == null))))?(((((map__25647.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__25647.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__25647):map__25647);
|
||||
var request = map__25647__$1;
|
||||
var request_method = cljs.core.get.call(null,map__25647__$1,new cljs.core.Keyword(null,"request-method","request-method",1764796830));
|
||||
if(cljs.core._EQ_.call(null,request_method,new cljs.core.Keyword(null,"jsonp","jsonp",226119588))){
|
||||
return cljs_http.core.jsonp.call(null,request);
|
||||
} else {
|
||||
return cljs_http.core.xhr.call(null,request);
|
||||
}
|
||||
});
|
||||
|
||||
//# sourceMappingURL=core.js.map
|
||||
File diff suppressed because one or more lines are too long
|
|
@ -0,0 +1,77 @@
|
|||
(ns cljs-http.util
|
||||
(:refer-clojure :exclude [uri?])
|
||||
(:import goog.Uri)
|
||||
(:require [clojure.string :refer [blank? capitalize join split lower-case]]
|
||||
[cognitect.transit :as t]
|
||||
[goog.userAgent :as agent]
|
||||
[no.en.core :refer [base64-encode]]))
|
||||
|
||||
(defn basic-auth
|
||||
"Returns the value of the HTTP basic authentication header for
|
||||
`credentials`."
|
||||
[credentials]
|
||||
(if credentials
|
||||
(let [[username password]
|
||||
(if (map? credentials)
|
||||
(map credentials [:username :password])
|
||||
credentials)]
|
||||
(str "Basic " (base64-encode (str username ":" password))))))
|
||||
|
||||
(defn build-url
|
||||
"Build the url from the request map."
|
||||
[{:keys [scheme server-name server-port uri query-string]}]
|
||||
(str (doto (Uri.)
|
||||
(.setScheme (name (or scheme :http)))
|
||||
(.setDomain server-name)
|
||||
(.setPort server-port)
|
||||
(.setPath uri)
|
||||
(.setQuery query-string true))))
|
||||
|
||||
(defn camelize
|
||||
"Returns dash separated string `s` in camel case."
|
||||
[s]
|
||||
(->> (split (str s) #"-")
|
||||
(map capitalize)
|
||||
(join "-")))
|
||||
|
||||
(defn build-headers
|
||||
"Build the headers from the map."
|
||||
[m] (clj->js (zipmap (map camelize (keys m)) (vals m))))
|
||||
|
||||
(defn user-agent
|
||||
"Returns the user agent."
|
||||
[] (agent/getUserAgentString))
|
||||
|
||||
(defn android?
|
||||
"Returns true if the user agent is an Android client."
|
||||
[] (re-matches #"(?i).*android.*" (user-agent)))
|
||||
|
||||
(defn transit-decode
|
||||
"Transit decode an object from `s`."
|
||||
[s type opts]
|
||||
(let [rdr (t/reader type opts)]
|
||||
(t/read rdr s)))
|
||||
|
||||
(defn transit-encode
|
||||
"Transit encode `x` into a String."
|
||||
[x type opts]
|
||||
(let [wrtr (t/writer type opts)]
|
||||
(t/write wrtr x)))
|
||||
|
||||
(defn json-decode
|
||||
"JSON decode an object from `s`."
|
||||
[s]
|
||||
(let [v (if-not (clojure.string/blank? s) (js/JSON.parse s))]
|
||||
(when (some? v)
|
||||
(js->clj v :keywordize-keys true))))
|
||||
|
||||
(defn json-encode
|
||||
"JSON encode `x` into a String."
|
||||
[x] (js/JSON.stringify (clj->js x)))
|
||||
|
||||
(defn parse-headers [headers]
|
||||
(reduce
|
||||
#(let [[k v] (split %2 #":\s+")]
|
||||
(if (or (blank? k) (blank? v))
|
||||
%1 (assoc %1 (lower-case k) v)))
|
||||
{} (split (or headers "") #"(\n)|(\r)|(\r\n)|(\n\r)")))
|
||||
File diff suppressed because one or more lines are too long
128
resources/public/target/cljsbuild-compiler-1/cljs_http/util.js
Normal file
128
resources/public/target/cljsbuild-compiler-1/cljs_http/util.js
Normal file
|
|
@ -0,0 +1,128 @@
|
|||
// Compiled by ClojureScript 1.10.520 {}
|
||||
goog.provide('cljs_http.util');
|
||||
goog.require('cljs.core');
|
||||
goog.require('goog.Uri');
|
||||
goog.require('clojure.string');
|
||||
goog.require('cognitect.transit');
|
||||
goog.require('goog.userAgent');
|
||||
goog.require('no.en.core');
|
||||
/**
|
||||
* Returns the value of the HTTP basic authentication header for
|
||||
* `credentials`.
|
||||
*/
|
||||
cljs_http.util.basic_auth = (function cljs_http$util$basic_auth(credentials){
|
||||
if(cljs.core.truth_(credentials)){
|
||||
var vec__22294 = ((cljs.core.map_QMARK_.call(null,credentials))?cljs.core.map.call(null,credentials,new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"username","username",1605666410),new cljs.core.Keyword(null,"password","password",417022471)], null)):credentials);
|
||||
var username = cljs.core.nth.call(null,vec__22294,(0),null);
|
||||
var password = cljs.core.nth.call(null,vec__22294,(1),null);
|
||||
return ["Basic ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(no.en.core.base64_encode.call(null,[cljs.core.str.cljs$core$IFn$_invoke$arity$1(username),":",cljs.core.str.cljs$core$IFn$_invoke$arity$1(password)].join('')))].join('');
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
/**
|
||||
* Build the url from the request map.
|
||||
*/
|
||||
cljs_http.util.build_url = (function cljs_http$util$build_url(p__22297){
|
||||
var map__22298 = p__22297;
|
||||
var map__22298__$1 = (((((!((map__22298 == null))))?(((((map__22298.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__22298.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__22298):map__22298);
|
||||
var scheme = cljs.core.get.call(null,map__22298__$1,new cljs.core.Keyword(null,"scheme","scheme",90199613));
|
||||
var server_name = cljs.core.get.call(null,map__22298__$1,new cljs.core.Keyword(null,"server-name","server-name",-1012104295));
|
||||
var server_port = cljs.core.get.call(null,map__22298__$1,new cljs.core.Keyword(null,"server-port","server-port",663745648));
|
||||
var uri = cljs.core.get.call(null,map__22298__$1,new cljs.core.Keyword(null,"uri","uri",-774711847));
|
||||
var query_string = cljs.core.get.call(null,map__22298__$1,new cljs.core.Keyword(null,"query-string","query-string",-1018845061));
|
||||
return cljs.core.str.cljs$core$IFn$_invoke$arity$1((function (){var G__22301 = (new goog.Uri());
|
||||
G__22301.setScheme(cljs.core.name.call(null,(function (){var or__4131__auto__ = scheme;
|
||||
if(cljs.core.truth_(or__4131__auto__)){
|
||||
return or__4131__auto__;
|
||||
} else {
|
||||
return new cljs.core.Keyword(null,"http","http",382524695);
|
||||
}
|
||||
})()));
|
||||
|
||||
G__22301.setDomain(server_name);
|
||||
|
||||
G__22301.setPort(server_port);
|
||||
|
||||
G__22301.setPath(uri);
|
||||
|
||||
G__22301.setQuery(query_string,true);
|
||||
|
||||
return G__22301;
|
||||
})());
|
||||
});
|
||||
/**
|
||||
* Returns dash separated string `s` in camel case.
|
||||
*/
|
||||
cljs_http.util.camelize = (function cljs_http$util$camelize(s){
|
||||
return clojure.string.join.call(null,"-",cljs.core.map.call(null,clojure.string.capitalize,clojure.string.split.call(null,cljs.core.str.cljs$core$IFn$_invoke$arity$1(s),/-/)));
|
||||
});
|
||||
/**
|
||||
* Build the headers from the map.
|
||||
*/
|
||||
cljs_http.util.build_headers = (function cljs_http$util$build_headers(m){
|
||||
return cljs.core.clj__GT_js.call(null,cljs.core.zipmap.call(null,cljs.core.map.call(null,cljs_http.util.camelize,cljs.core.keys.call(null,m)),cljs.core.vals.call(null,m)));
|
||||
});
|
||||
/**
|
||||
* Returns the user agent.
|
||||
*/
|
||||
cljs_http.util.user_agent = (function cljs_http$util$user_agent(){
|
||||
return goog.userAgent.getUserAgentString();
|
||||
});
|
||||
/**
|
||||
* Returns true if the user agent is an Android client.
|
||||
*/
|
||||
cljs_http.util.android_QMARK_ = (function cljs_http$util$android_QMARK_(){
|
||||
return cljs.core.re_matches.call(null,/.*android.*/i,cljs_http.util.user_agent.call(null));
|
||||
});
|
||||
/**
|
||||
* Transit decode an object from `s`.
|
||||
*/
|
||||
cljs_http.util.transit_decode = (function cljs_http$util$transit_decode(s,type,opts){
|
||||
var rdr = cognitect.transit.reader.call(null,type,opts);
|
||||
return cognitect.transit.read.call(null,rdr,s);
|
||||
});
|
||||
/**
|
||||
* Transit encode `x` into a String.
|
||||
*/
|
||||
cljs_http.util.transit_encode = (function cljs_http$util$transit_encode(x,type,opts){
|
||||
var wrtr = cognitect.transit.writer.call(null,type,opts);
|
||||
return cognitect.transit.write.call(null,wrtr,x);
|
||||
});
|
||||
/**
|
||||
* JSON decode an object from `s`.
|
||||
*/
|
||||
cljs_http.util.json_decode = (function cljs_http$util$json_decode(s){
|
||||
var v = (((!(clojure.string.blank_QMARK_.call(null,s))))?JSON.parse(s):null);
|
||||
if((!((v == null)))){
|
||||
return cljs.core.js__GT_clj.call(null,v,new cljs.core.Keyword(null,"keywordize-keys","keywordize-keys",1310784252),true);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
/**
|
||||
* JSON encode `x` into a String.
|
||||
*/
|
||||
cljs_http.util.json_encode = (function cljs_http$util$json_encode(x){
|
||||
return JSON.stringify(cljs.core.clj__GT_js.call(null,x));
|
||||
});
|
||||
cljs_http.util.parse_headers = (function cljs_http$util$parse_headers(headers){
|
||||
return cljs.core.reduce.call(null,(function (p1__22303_SHARP_,p2__22302_SHARP_){
|
||||
var vec__22304 = clojure.string.split.call(null,p2__22302_SHARP_,/:\s+/);
|
||||
var k = cljs.core.nth.call(null,vec__22304,(0),null);
|
||||
var v = cljs.core.nth.call(null,vec__22304,(1),null);
|
||||
if(((clojure.string.blank_QMARK_.call(null,k)) || (clojure.string.blank_QMARK_.call(null,v)))){
|
||||
return p1__22303_SHARP_;
|
||||
} else {
|
||||
return cljs.core.assoc.call(null,p1__22303_SHARP_,clojure.string.lower_case.call(null,k),v);
|
||||
}
|
||||
}),cljs.core.PersistentArrayMap.EMPTY,clojure.string.split.call(null,(function (){var or__4131__auto__ = headers;
|
||||
if(cljs.core.truth_(or__4131__auto__)){
|
||||
return or__4131__auto__;
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
})(),/(\n)|(\r)|(\r\n)|(\n\r)/));
|
||||
});
|
||||
|
||||
//# sourceMappingURL=util.js.map
|
||||
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"\/home\/simon\/workspace\/geocsv-lite\/target\/cljsbuild-compiler-1\/cljs_http\/util.js","sources":["util.cljs"],"lineCount":128,"mappings":";AAAA;;;;;;;AAQA;;;;4BAAA,5BAAMA,gEAGHC;AAHH,AAIE,oBAAIA;AACF,IAAAC,aACM,EAAI,AAACI,+BAAKL,cACR,oCAAA,mFAAA,6DAAA,pLAACM,wBAAIN,iOACLA;eAHR,AAAAE,wBAAAD,WAAA,IAAA,lDAAOE;eAAP,AAAAD,wBAAAD,WAAA,IAAA,lDAAgBG;AAAhB,AAIE,QAAA,qDAAc,AAACG,mCAAc,uDAAA,VAAKJ,0DAAaC;;AALnD;;;AAOF;;;2BAAA,mCAAAI,9DAAMM;AAAN,AAAA,IAAAL,aAAAD;IAAAC,iBAAA,EAAA,EAAA,GAAA,CAAAA,cAAA,SAAA,EAAA,EAAA,CAAA,AAAAA,iDAAA,WAAA,CAAAC,gCAAA,AAAAD,+BAAA,KAAA,OAAA,QAAA,AAAAE,0BAAAC,mBAAAH,YAAAA;aAAA,AAAAI,wBAAAJ,eAAA,hDAEWM;kBAFX,AAAAF,wBAAAJ,eAAA,rDAEkBO;kBAFlB,AAAAH,wBAAAJ,eAAA,rDAE8BQ;UAF9B,AAAAJ,wBAAAJ,eAAA,7CAE0CS;mBAF1C,AAAAL,wBAAAJ,eAAA,tDAE8CU;AAF9C,AAGE,mDAAK,iBAAAC,WAAM,KAAAC;AAAN,AAAA,AAAAD,mBACc,AAACE,yBAAK,iBAAAC,mBAAIR;AAAJ,AAAA,oBAAAQ;AAAAA;;AAAA;;;;AADpB,AAAAH,mBAEcJ;;AAFd,AAAAI,iBAGYH;;AAHZ,AAAAG,iBAIYF;;AAJZ,AAAAE,+BAAA,bAKaD;;AALbC;;;AAOP;;;0BAAA,1BAAMI,4DAEHC;AAFH,2FAGO,8EAAA,9EAACC,+BAAM,4CAAKD,7HACZ,AAACnB,wBAAIqB,jEACL,qCAAA,9BAACC;;AAER;;;+BAAA,\/BAAMC,sEAEHC;AAFH,AAEM,OAACC,+BAAQ,AAACC,2BAAO,AAAC1B,wBAAIkB,wBAAS,AAACS,yBAAKH,IAAI,AAACI,yBAAKJ;;AAErD;;;4BAAA,5BAAMK;AAAN,AAEK,OAACC;;AAEN;;;gCAAA,hCAAMC;AAAN,AAEK,sCAAA,\/BAACC,8CAA8B,AAACH;;AAErC;;;gCAAA,hCAAMI,wEAEHd,EAAEe,KAAKC;AAFV,AAGE,IAAMC,MAAI,AAACC,mCAASH,KAAKC;AAAzB,AACE,OAACG,iCAAOF,IAAIjB;;AAEhB;;;gCAAA,hCAAMoB,wEAEHC,EAAEN,KAAKC;AAFV,AAGE,IAAMM,OAAK,AAACC,mCAASR,KAAKC;AAA1B,AACE,OAACQ,kCAAQF,KAAKD;;AAElB;;;6BAAA,7BAAMI,kEAEHzB;AAFH,AAGE,IAAM0B,IAAE,EAAA,6DAAA,1DAAQ,AAACC,sCAAsB3B,MAAG,AAAC4B,WAAc5B;AAAzD,AACE,GAAM,GAAA,MAAA,LAAO0B;AAAb,AACE,wCAAA,2EAAA,5GAACG,+BAAQH;;AADX;;;AAGJ;;;6BAAA,7BAAMI,kEAEHT;AAFH,AAEM,OAACU,eAAkB,AAACzB,+BAAQe;;AAElC,+BAAA,\/BAAMW,sEAAeC;AAArB,AACE,kCAAA,WAAAC,iBAAAC,vDAACC;AAAD,AACE,IAAAC,aAAY,+BAAAF,iBAAA,hDAAClC;QAAb,AAAAxB,wBAAA4D,WAAA,IAAA,3CAAOC;QAAP,AAAA7D,wBAAA4D,WAAA,IAAA,3CAASX;AAAT,AACE,GAAI,EAAI,AAACC,sCAAOW,QAAG,AAACX,sCAAOD;AAA3BQ;;AACK,iCAAAA,1BAACK,2CAAS,AAACC,oCAAWF,GAAGZ;;GAHlC,mCAII,AAACzB,+BAAM,iBAAAH,mBAAImC;AAAJ,AAAA,oBAAAnC;AAAAA;;AAAA;;KAAP","names":["cljs-http.util\/basic-auth","credentials","vec__22294","cljs.core\/nth","username","password","cljs.core\/map?","cljs.core\/map","no.en.core\/base64-encode","p__22297","map__22298","cljs.core\/PROTOCOL_SENTINEL","cljs.core\/apply","cljs.core\/hash-map","cljs.core\/get","cljs-http.util\/build-url","scheme","server-name","server-port","uri","query-string","G__22301","goog\/Uri","cljs.core\/name","or__4131__auto__","cljs-http.util\/camelize","s","clojure.string\/split","clojure.string\/capitalize","clojure.string\/join","cljs-http.util\/build-headers","m","cljs.core\/clj->js","cljs.core\/zipmap","cljs.core\/keys","cljs.core\/vals","cljs-http.util\/user-agent","goog.userAgent\/getUserAgentString","cljs-http.util\/android?","cljs.core\/re-matches","cljs-http.util\/transit-decode","type","opts","rdr","cognitect.transit\/reader","cognitect.transit\/read","cljs-http.util\/transit-encode","x","wrtr","cognitect.transit\/writer","cognitect.transit\/write","cljs-http.util\/json-decode","v","clojure.string\/blank?","js\/JSON.parse","cljs.core\/js->clj","cljs-http.util\/json-encode","js\/JSON.stringify","cljs-http.util\/parse-headers","headers","p1__22303#","p2__22302#","cljs.core\/reduce","vec__22304","k","cljs.core\/assoc","clojure.string\/lower-case"]}
|
||||
|
|
@ -0,0 +1 @@
|
|||
{:infer-externs true, :output-dir "target/cljsbuild-compiler-1", :externs ["L" "Papa" "closure-js/externs"], :optimizations :none, :warnings true, :output-to "resources/public/js/compiled/geocsv_lite.js", :output-wrapper false, :libs ["closure-js/libs"], :main geocsv-lite.core, :pretty-print true}
|
||||
|
|
@ -0,0 +1,152 @@
|
|||
;; Copyright (c) Rich Hickey. All rights reserved.
|
||||
;; The use and distribution terms for this software are covered by the
|
||||
;; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
|
||||
;; which can be found in the file epl-v10.html at the root of this distribution.
|
||||
;; By using this software in any fashion, you are agreeing to be bound by
|
||||
;; the terms of this license.
|
||||
;; You must not remove this notice, or any other, from this software.
|
||||
|
||||
(ns clojure.browser.dom
|
||||
(:require [goog.dom :as gdom]
|
||||
[goog.object :as gobject]))
|
||||
|
||||
(defn append [parent & children]
|
||||
(apply gdom/append parent children)
|
||||
parent)
|
||||
|
||||
(defprotocol DOMBuilder
|
||||
(-element [this] [this attrs-or-children] [this attrs children]))
|
||||
|
||||
(defn log [& args]
|
||||
(.log js/console (apply pr-str args)))
|
||||
|
||||
(defn log-obj [obj]
|
||||
(.log js/console obj))
|
||||
|
||||
(extend-protocol DOMBuilder
|
||||
|
||||
string
|
||||
(-element
|
||||
([this]
|
||||
(log "string (-element " this ")")
|
||||
(cond (keyword? this) (gdom/createElement (name this))
|
||||
:else (gdom/createTextNode (name this))))
|
||||
|
||||
([this attrs-or-children]
|
||||
(log "string (-element " this " " attrs-or-children ")")
|
||||
(let [attrs (first attrs-or-children)]
|
||||
(if (map? attrs)
|
||||
(-element this attrs (rest attrs-or-children))
|
||||
(-element this nil attrs-or-children))))
|
||||
|
||||
([this attrs children]
|
||||
(log "string (-element " this " " attrs " " children ")")
|
||||
(let [str-attrs (if (and (map? attrs) (seq attrs))
|
||||
(reduce (fn [o [k v]]
|
||||
(let [o (if (nil? o) (js-obj) o)]
|
||||
(log "o = " o)
|
||||
(log "k = " k)
|
||||
(log "v = " v)
|
||||
(when (or (keyword? k)
|
||||
(string? k))
|
||||
(doto o (gobject/set (name k) v)))))
|
||||
(js-obj)
|
||||
attrs)
|
||||
nil)]
|
||||
(log-obj str-attrs)
|
||||
(if (seq children)
|
||||
(apply gdom/createDom
|
||||
(name this)
|
||||
str-attrs
|
||||
(map -element children))
|
||||
(gdom/createDom (name this)
|
||||
str-attrs)))))
|
||||
|
||||
PersistentVector
|
||||
(-element
|
||||
[this]
|
||||
(log "PersistentVector (-element " this ")")
|
||||
(let [tag (first this)
|
||||
attrs (second this)
|
||||
children (drop 2 this)]
|
||||
(if (map? attrs)
|
||||
(-element tag attrs children)
|
||||
(-element tag nil (rest this)))))
|
||||
|
||||
js/Element
|
||||
(-element [this]
|
||||
(log "js/Element (-element " this ")")
|
||||
this))
|
||||
|
||||
(defn element
|
||||
([tag-or-text]
|
||||
(log "(element " tag-or-text ")")
|
||||
(-element tag-or-text))
|
||||
([tag & children]
|
||||
(log "(element " tag " " children ")")
|
||||
(let [attrs (first children)]
|
||||
(if (map? attrs)
|
||||
(-element tag attrs (rest children))
|
||||
(-element tag nil children)))))
|
||||
|
||||
(defn remove-children
|
||||
"Remove all children from the element with the passed id."
|
||||
[id]
|
||||
(let [parent (gdom/getElement (name id))]
|
||||
(do (gdom/removeChildren parent))))
|
||||
|
||||
(defn get-element [id]
|
||||
(gdom/getElement (name id)))
|
||||
|
||||
(defn html->dom [s]
|
||||
(gdom/htmlToDocumentFragment s))
|
||||
|
||||
(defn insert-at [parent child index]
|
||||
(gdom/insertChildAt parent child index))
|
||||
|
||||
(defn ensure-element
|
||||
"Coerce the argument to a dom element if possible."
|
||||
[e]
|
||||
(cond (keyword? e) (get-element e)
|
||||
(string? e) (html->dom e)
|
||||
:else e))
|
||||
|
||||
(defn replace-node
|
||||
"Replace old-node with new-node. old-node can be an element or a
|
||||
keyword which is the id of the node to replace. new-node can be an
|
||||
element or an html string."
|
||||
[old-node new-node]
|
||||
(let [old-node (ensure-element old-node)
|
||||
new-node (ensure-element new-node)]
|
||||
(gdom/replaceNode new-node old-node)
|
||||
new-node))
|
||||
|
||||
(defn set-text
|
||||
"Set the text content for the passed element returning the
|
||||
element. If a keyword is passed in the place of e, the element with
|
||||
that id will be used and returned."
|
||||
[e s]
|
||||
(gdom/setTextContent (ensure-element e) s))
|
||||
|
||||
(defn get-value
|
||||
"Get the value of an element."
|
||||
[e]
|
||||
(.-value (ensure-element e)))
|
||||
|
||||
(defn set-properties
|
||||
"Set properties on an element"
|
||||
[e m]
|
||||
(gdom/setProperties (ensure-element e)
|
||||
(apply gobject/create (interleave (keys m) (vals m)))))
|
||||
|
||||
(defn set-value
|
||||
"Set the value property for an element."
|
||||
[e v]
|
||||
(set-properties e {"value" v}))
|
||||
|
||||
(defn click-element
|
||||
[e]
|
||||
(.click (ensure-element e) ()))
|
||||
|
||||
;; TODO CSS class manipulation
|
||||
;; TODO Query syntax
|
||||
File diff suppressed because one or more lines are too long
|
|
@ -0,0 +1,390 @@
|
|||
// Compiled by ClojureScript 1.10.520 {}
|
||||
goog.provide('clojure.browser.dom');
|
||||
goog.require('cljs.core');
|
||||
goog.require('goog.dom');
|
||||
goog.require('goog.object');
|
||||
clojure.browser.dom.append = (function clojure$browser$dom$append(var_args){
|
||||
var args__4736__auto__ = [];
|
||||
var len__4730__auto___25653 = arguments.length;
|
||||
var i__4731__auto___25654 = (0);
|
||||
while(true){
|
||||
if((i__4731__auto___25654 < len__4730__auto___25653)){
|
||||
args__4736__auto__.push((arguments[i__4731__auto___25654]));
|
||||
|
||||
var G__25655 = (i__4731__auto___25654 + (1));
|
||||
i__4731__auto___25654 = G__25655;
|
||||
continue;
|
||||
} else {
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
var argseq__4737__auto__ = ((((1) < args__4736__auto__.length))?(new cljs.core.IndexedSeq(args__4736__auto__.slice((1)),(0),null)):null);
|
||||
return clojure.browser.dom.append.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),argseq__4737__auto__);
|
||||
});
|
||||
|
||||
clojure.browser.dom.append.cljs$core$IFn$_invoke$arity$variadic = (function (parent,children){
|
||||
cljs.core.apply.call(null,goog.dom.append,parent,children);
|
||||
|
||||
return parent;
|
||||
});
|
||||
|
||||
clojure.browser.dom.append.cljs$lang$maxFixedArity = (1);
|
||||
|
||||
/** @this {Function} */
|
||||
clojure.browser.dom.append.cljs$lang$applyTo = (function (seq25651){
|
||||
var G__25652 = cljs.core.first.call(null,seq25651);
|
||||
var seq25651__$1 = cljs.core.next.call(null,seq25651);
|
||||
var self__4717__auto__ = this;
|
||||
return self__4717__auto__.cljs$core$IFn$_invoke$arity$variadic(G__25652,seq25651__$1);
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* @interface
|
||||
*/
|
||||
clojure.browser.dom.DOMBuilder = function(){};
|
||||
|
||||
clojure.browser.dom._element = (function clojure$browser$dom$_element(var_args){
|
||||
var G__25657 = arguments.length;
|
||||
switch (G__25657) {
|
||||
case 1:
|
||||
return clojure.browser.dom._element.cljs$core$IFn$_invoke$arity$1((arguments[(0)]));
|
||||
|
||||
break;
|
||||
case 2:
|
||||
return clojure.browser.dom._element.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)]));
|
||||
|
||||
break;
|
||||
case 3:
|
||||
return clojure.browser.dom._element.cljs$core$IFn$_invoke$arity$3((arguments[(0)]),(arguments[(1)]),(arguments[(2)]));
|
||||
|
||||
break;
|
||||
default:
|
||||
throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
clojure.browser.dom._element.cljs$core$IFn$_invoke$arity$1 = (function (this$){
|
||||
if((((!((this$ == null)))) && ((!((this$.clojure$browser$dom$DOMBuilder$_element$arity$1 == null)))))){
|
||||
return this$.clojure$browser$dom$DOMBuilder$_element$arity$1(this$);
|
||||
} else {
|
||||
var x__4433__auto__ = (((this$ == null))?null:this$);
|
||||
var m__4434__auto__ = (clojure.browser.dom._element[goog.typeOf(x__4433__auto__)]);
|
||||
if((!((m__4434__auto__ == null)))){
|
||||
return m__4434__auto__.call(null,this$);
|
||||
} else {
|
||||
var m__4431__auto__ = (clojure.browser.dom._element["_"]);
|
||||
if((!((m__4431__auto__ == null)))){
|
||||
return m__4431__auto__.call(null,this$);
|
||||
} else {
|
||||
throw cljs.core.missing_protocol.call(null,"DOMBuilder.-element",this$);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
clojure.browser.dom._element.cljs$core$IFn$_invoke$arity$2 = (function (this$,attrs_or_children){
|
||||
if((((!((this$ == null)))) && ((!((this$.clojure$browser$dom$DOMBuilder$_element$arity$2 == null)))))){
|
||||
return this$.clojure$browser$dom$DOMBuilder$_element$arity$2(this$,attrs_or_children);
|
||||
} else {
|
||||
var x__4433__auto__ = (((this$ == null))?null:this$);
|
||||
var m__4434__auto__ = (clojure.browser.dom._element[goog.typeOf(x__4433__auto__)]);
|
||||
if((!((m__4434__auto__ == null)))){
|
||||
return m__4434__auto__.call(null,this$,attrs_or_children);
|
||||
} else {
|
||||
var m__4431__auto__ = (clojure.browser.dom._element["_"]);
|
||||
if((!((m__4431__auto__ == null)))){
|
||||
return m__4431__auto__.call(null,this$,attrs_or_children);
|
||||
} else {
|
||||
throw cljs.core.missing_protocol.call(null,"DOMBuilder.-element",this$);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
clojure.browser.dom._element.cljs$core$IFn$_invoke$arity$3 = (function (this$,attrs,children){
|
||||
if((((!((this$ == null)))) && ((!((this$.clojure$browser$dom$DOMBuilder$_element$arity$3 == null)))))){
|
||||
return this$.clojure$browser$dom$DOMBuilder$_element$arity$3(this$,attrs,children);
|
||||
} else {
|
||||
var x__4433__auto__ = (((this$ == null))?null:this$);
|
||||
var m__4434__auto__ = (clojure.browser.dom._element[goog.typeOf(x__4433__auto__)]);
|
||||
if((!((m__4434__auto__ == null)))){
|
||||
return m__4434__auto__.call(null,this$,attrs,children);
|
||||
} else {
|
||||
var m__4431__auto__ = (clojure.browser.dom._element["_"]);
|
||||
if((!((m__4431__auto__ == null)))){
|
||||
return m__4431__auto__.call(null,this$,attrs,children);
|
||||
} else {
|
||||
throw cljs.core.missing_protocol.call(null,"DOMBuilder.-element",this$);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
clojure.browser.dom._element.cljs$lang$maxFixedArity = 3;
|
||||
|
||||
|
||||
clojure.browser.dom.log = (function clojure$browser$dom$log(var_args){
|
||||
var args__4736__auto__ = [];
|
||||
var len__4730__auto___25660 = arguments.length;
|
||||
var i__4731__auto___25661 = (0);
|
||||
while(true){
|
||||
if((i__4731__auto___25661 < len__4730__auto___25660)){
|
||||
args__4736__auto__.push((arguments[i__4731__auto___25661]));
|
||||
|
||||
var G__25662 = (i__4731__auto___25661 + (1));
|
||||
i__4731__auto___25661 = G__25662;
|
||||
continue;
|
||||
} else {
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
var argseq__4737__auto__ = ((((0) < args__4736__auto__.length))?(new cljs.core.IndexedSeq(args__4736__auto__.slice((0)),(0),null)):null);
|
||||
return clojure.browser.dom.log.cljs$core$IFn$_invoke$arity$variadic(argseq__4737__auto__);
|
||||
});
|
||||
|
||||
clojure.browser.dom.log.cljs$core$IFn$_invoke$arity$variadic = (function (args){
|
||||
return console.log(cljs.core.apply.call(null,cljs.core.pr_str,args));
|
||||
});
|
||||
|
||||
clojure.browser.dom.log.cljs$lang$maxFixedArity = (0);
|
||||
|
||||
/** @this {Function} */
|
||||
clojure.browser.dom.log.cljs$lang$applyTo = (function (seq25659){
|
||||
var self__4718__auto__ = this;
|
||||
return self__4718__auto__.cljs$core$IFn$_invoke$arity$variadic(cljs.core.seq.call(null,seq25659));
|
||||
});
|
||||
|
||||
clojure.browser.dom.log_obj = (function clojure$browser$dom$log_obj(obj){
|
||||
return console.log(obj);
|
||||
});
|
||||
goog.object.set(clojure.browser.dom.DOMBuilder,"string",true);
|
||||
|
||||
goog.object.set(clojure.browser.dom._element,"string",(function() {
|
||||
var G__25672 = null;
|
||||
var G__25672__1 = (function (this$){
|
||||
clojure.browser.dom.log.call(null,"string (-element ",this$,")");
|
||||
|
||||
if((this$ instanceof cljs.core.Keyword)){
|
||||
return goog.dom.createElement(cljs.core.name.call(null,this$));
|
||||
} else {
|
||||
return goog.dom.createTextNode(cljs.core.name.call(null,this$));
|
||||
|
||||
}
|
||||
});
|
||||
var G__25672__2 = (function (this$,attrs_or_children){
|
||||
clojure.browser.dom.log.call(null,"string (-element ",this$," ",attrs_or_children,")");
|
||||
|
||||
var attrs = cljs.core.first.call(null,attrs_or_children);
|
||||
if(cljs.core.map_QMARK_.call(null,attrs)){
|
||||
return clojure.browser.dom._element.call(null,this$,attrs,cljs.core.rest.call(null,attrs_or_children));
|
||||
} else {
|
||||
return clojure.browser.dom._element.call(null,this$,null,attrs_or_children);
|
||||
}
|
||||
});
|
||||
var G__25672__3 = (function (this$,attrs,children){
|
||||
clojure.browser.dom.log.call(null,"string (-element ",this$," ",attrs," ",children,")");
|
||||
|
||||
var str_attrs = ((((cljs.core.map_QMARK_.call(null,attrs)) && (cljs.core.seq.call(null,attrs))))?cljs.core.reduce.call(null,(function (o,p__25663){
|
||||
var vec__25664 = p__25663;
|
||||
var k = cljs.core.nth.call(null,vec__25664,(0),null);
|
||||
var v = cljs.core.nth.call(null,vec__25664,(1),null);
|
||||
var o__$1 = (((o == null))?({}):o);
|
||||
clojure.browser.dom.log.call(null,"o = ",o__$1);
|
||||
|
||||
clojure.browser.dom.log.call(null,"k = ",k);
|
||||
|
||||
clojure.browser.dom.log.call(null,"v = ",v);
|
||||
|
||||
if((((k instanceof cljs.core.Keyword)) || (typeof k === 'string'))){
|
||||
var G__25669 = o__$1;
|
||||
goog.object.set(G__25669,cljs.core.name.call(null,k),v);
|
||||
|
||||
return G__25669;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}),({}),attrs):null);
|
||||
clojure.browser.dom.log_obj.call(null,str_attrs);
|
||||
|
||||
if(cljs.core.seq.call(null,children)){
|
||||
return cljs.core.apply.call(null,goog.dom.createDom,cljs.core.name.call(null,this$),str_attrs,cljs.core.map.call(null,clojure.browser.dom._element,children));
|
||||
} else {
|
||||
return goog.dom.createDom(cljs.core.name.call(null,this$),str_attrs);
|
||||
}
|
||||
});
|
||||
G__25672 = function(this$,attrs,children){
|
||||
switch(arguments.length){
|
||||
case 1:
|
||||
return G__25672__1.call(this,this$);
|
||||
case 2:
|
||||
return G__25672__2.call(this,this$,attrs);
|
||||
case 3:
|
||||
return G__25672__3.call(this,this$,attrs,children);
|
||||
}
|
||||
throw(new Error('Invalid arity: ' + arguments.length));
|
||||
};
|
||||
G__25672.cljs$core$IFn$_invoke$arity$1 = G__25672__1;
|
||||
G__25672.cljs$core$IFn$_invoke$arity$2 = G__25672__2;
|
||||
G__25672.cljs$core$IFn$_invoke$arity$3 = G__25672__3;
|
||||
return G__25672;
|
||||
})()
|
||||
);
|
||||
|
||||
cljs.core.PersistentVector.prototype.clojure$browser$dom$DOMBuilder$ = cljs.core.PROTOCOL_SENTINEL;
|
||||
|
||||
cljs.core.PersistentVector.prototype.clojure$browser$dom$DOMBuilder$_element$arity$1 = (function (this$){
|
||||
var this$__$1 = this;
|
||||
clojure.browser.dom.log.call(null,"PersistentVector (-element ",this$__$1,")");
|
||||
|
||||
var tag = cljs.core.first.call(null,this$__$1);
|
||||
var attrs = cljs.core.second.call(null,this$__$1);
|
||||
var children = cljs.core.drop.call(null,(2),this$__$1);
|
||||
if(cljs.core.map_QMARK_.call(null,attrs)){
|
||||
return clojure.browser.dom._element.call(null,tag,attrs,children);
|
||||
} else {
|
||||
return clojure.browser.dom._element.call(null,tag,null,cljs.core.rest.call(null,this$__$1));
|
||||
}
|
||||
});
|
||||
|
||||
Element.prototype.clojure$browser$dom$DOMBuilder$ = cljs.core.PROTOCOL_SENTINEL;
|
||||
|
||||
Element.prototype.clojure$browser$dom$DOMBuilder$_element$arity$1 = (function (this$){
|
||||
var this$__$1 = this;
|
||||
clojure.browser.dom.log.call(null,"js/Element (-element ",this$__$1,")");
|
||||
|
||||
return this$__$1;
|
||||
});
|
||||
clojure.browser.dom.element = (function clojure$browser$dom$element(var_args){
|
||||
var G__25676 = arguments.length;
|
||||
switch (G__25676) {
|
||||
case 1:
|
||||
return clojure.browser.dom.element.cljs$core$IFn$_invoke$arity$1((arguments[(0)]));
|
||||
|
||||
break;
|
||||
default:
|
||||
var args_arr__4751__auto__ = [];
|
||||
var len__4730__auto___25678 = arguments.length;
|
||||
var i__4731__auto___25679 = (0);
|
||||
while(true){
|
||||
if((i__4731__auto___25679 < len__4730__auto___25678)){
|
||||
args_arr__4751__auto__.push((arguments[i__4731__auto___25679]));
|
||||
|
||||
var G__25680 = (i__4731__auto___25679 + (1));
|
||||
i__4731__auto___25679 = G__25680;
|
||||
continue;
|
||||
} else {
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
var argseq__4752__auto__ = (new cljs.core.IndexedSeq(args_arr__4751__auto__.slice((1)),(0),null));
|
||||
return clojure.browser.dom.element.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),argseq__4752__auto__);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
clojure.browser.dom.element.cljs$core$IFn$_invoke$arity$1 = (function (tag_or_text){
|
||||
clojure.browser.dom.log.call(null,"(element ",tag_or_text,")");
|
||||
|
||||
return clojure.browser.dom._element.call(null,tag_or_text);
|
||||
});
|
||||
|
||||
clojure.browser.dom.element.cljs$core$IFn$_invoke$arity$variadic = (function (tag,children){
|
||||
clojure.browser.dom.log.call(null,"(element ",tag," ",children,")");
|
||||
|
||||
var attrs = cljs.core.first.call(null,children);
|
||||
if(cljs.core.map_QMARK_.call(null,attrs)){
|
||||
return clojure.browser.dom._element.call(null,tag,attrs,cljs.core.rest.call(null,children));
|
||||
} else {
|
||||
return clojure.browser.dom._element.call(null,tag,null,children);
|
||||
}
|
||||
});
|
||||
|
||||
/** @this {Function} */
|
||||
clojure.browser.dom.element.cljs$lang$applyTo = (function (seq25674){
|
||||
var G__25675 = cljs.core.first.call(null,seq25674);
|
||||
var seq25674__$1 = cljs.core.next.call(null,seq25674);
|
||||
var self__4717__auto__ = this;
|
||||
return self__4717__auto__.cljs$core$IFn$_invoke$arity$variadic(G__25675,seq25674__$1);
|
||||
});
|
||||
|
||||
clojure.browser.dom.element.cljs$lang$maxFixedArity = (1);
|
||||
|
||||
/**
|
||||
* Remove all children from the element with the passed id.
|
||||
*/
|
||||
clojure.browser.dom.remove_children = (function clojure$browser$dom$remove_children(id){
|
||||
var parent = goog.dom.getElement(cljs.core.name.call(null,id));
|
||||
return goog.dom.removeChildren(parent);
|
||||
});
|
||||
clojure.browser.dom.get_element = (function clojure$browser$dom$get_element(id){
|
||||
return goog.dom.getElement(cljs.core.name.call(null,id));
|
||||
});
|
||||
clojure.browser.dom.html__GT_dom = (function clojure$browser$dom$html__GT_dom(s){
|
||||
return goog.dom.htmlToDocumentFragment(s);
|
||||
});
|
||||
clojure.browser.dom.insert_at = (function clojure$browser$dom$insert_at(parent,child,index){
|
||||
return goog.dom.insertChildAt(parent,child,index);
|
||||
});
|
||||
/**
|
||||
* Coerce the argument to a dom element if possible.
|
||||
*/
|
||||
clojure.browser.dom.ensure_element = (function clojure$browser$dom$ensure_element(e){
|
||||
if((e instanceof cljs.core.Keyword)){
|
||||
return clojure.browser.dom.get_element.call(null,e);
|
||||
} else {
|
||||
if(typeof e === 'string'){
|
||||
return clojure.browser.dom.html__GT_dom.call(null,e);
|
||||
} else {
|
||||
return e;
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
/**
|
||||
* Replace old-node with new-node. old-node can be an element or a
|
||||
* keyword which is the id of the node to replace. new-node can be an
|
||||
* element or an html string.
|
||||
*/
|
||||
clojure.browser.dom.replace_node = (function clojure$browser$dom$replace_node(old_node,new_node){
|
||||
var old_node__$1 = clojure.browser.dom.ensure_element.call(null,old_node);
|
||||
var new_node__$1 = clojure.browser.dom.ensure_element.call(null,new_node);
|
||||
goog.dom.replaceNode(new_node__$1,old_node__$1);
|
||||
|
||||
return new_node__$1;
|
||||
});
|
||||
/**
|
||||
* Set the text content for the passed element returning the
|
||||
* element. If a keyword is passed in the place of e, the element with
|
||||
* that id will be used and returned.
|
||||
*/
|
||||
clojure.browser.dom.set_text = (function clojure$browser$dom$set_text(e,s){
|
||||
return goog.dom.setTextContent(clojure.browser.dom.ensure_element.call(null,e),s);
|
||||
});
|
||||
/**
|
||||
* Get the value of an element.
|
||||
*/
|
||||
clojure.browser.dom.get_value = (function clojure$browser$dom$get_value(e){
|
||||
return clojure.browser.dom.ensure_element.call(null,e).value;
|
||||
});
|
||||
/**
|
||||
* Set properties on an element
|
||||
*/
|
||||
clojure.browser.dom.set_properties = (function clojure$browser$dom$set_properties(e,m){
|
||||
return goog.dom.setProperties(clojure.browser.dom.ensure_element.call(null,e),cljs.core.apply.call(null,goog.object.create,cljs.core.interleave.call(null,cljs.core.keys.call(null,m),cljs.core.vals.call(null,m))));
|
||||
});
|
||||
/**
|
||||
* Set the value property for an element.
|
||||
*/
|
||||
clojure.browser.dom.set_value = (function clojure$browser$dom$set_value(e,v){
|
||||
return clojure.browser.dom.set_properties.call(null,e,new cljs.core.PersistentArrayMap(null, 1, ["value",v], null));
|
||||
});
|
||||
clojure.browser.dom.click_element = (function clojure$browser$dom$click_element(e){
|
||||
return clojure.browser.dom.ensure_element.call(null,e).click(cljs.core.List.EMPTY);
|
||||
});
|
||||
|
||||
//# sourceMappingURL=dom.js.map
|
||||
File diff suppressed because one or more lines are too long
289
resources/public/target/cljsbuild-compiler-1/clojure/string.cljs
Normal file
289
resources/public/target/cljsbuild-compiler-1/clojure/string.cljs
Normal file
|
|
@ -0,0 +1,289 @@
|
|||
; Copyright (c) Rich Hickey. All rights reserved.
|
||||
; The use and distribution terms for this software are covered by the
|
||||
; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
|
||||
; which can be found in the file epl-v10.html at the root of this distribution.
|
||||
; By using this software in any fashion, you are agreeing to be bound by
|
||||
; the terms of this license.
|
||||
; You must not remove this notice, or any other, from this software.
|
||||
|
||||
(ns clojure.string
|
||||
(:refer-clojure :exclude [replace reverse])
|
||||
(:require [goog.string :as gstring])
|
||||
(:import [goog.string StringBuffer]))
|
||||
|
||||
(defn- seq-reverse
|
||||
[coll]
|
||||
(reduce conj () coll))
|
||||
|
||||
(def ^:private re-surrogate-pair
|
||||
(js/RegExp. "([\\uD800-\\uDBFF])([\\uDC00-\\uDFFF])" "g"))
|
||||
|
||||
(defn reverse
|
||||
"Returns s with its characters reversed."
|
||||
[s]
|
||||
(-> (.replace s re-surrogate-pair "$2$1")
|
||||
(.. (split "") (reverse) (join ""))))
|
||||
|
||||
(defn- replace-all
|
||||
[s re replacement]
|
||||
(let [r (js/RegExp. (.-source re)
|
||||
(cond-> "g"
|
||||
(.-ignoreCase re) (str "i")
|
||||
(.-multiline re) (str "m")
|
||||
(.-unicode re) (str "u")))]
|
||||
(.replace s r replacement)))
|
||||
|
||||
(defn- replace-with
|
||||
[f]
|
||||
(fn [& args]
|
||||
(let [matches (drop-last 2 args)]
|
||||
(if (= (count matches) 1)
|
||||
(f (first matches))
|
||||
(f (vec matches))))))
|
||||
|
||||
(defn replace
|
||||
"Replaces all instance of match with replacement in s.
|
||||
|
||||
match/replacement can be:
|
||||
|
||||
string / string
|
||||
pattern / (string or function of match).
|
||||
|
||||
See also replace-first.
|
||||
|
||||
The replacement is literal (i.e. none of its characters are treated
|
||||
specially) for all cases above except pattern / string.
|
||||
|
||||
For pattern / string, $1, $2, etc. in the replacement string are
|
||||
substituted with the string that matched the corresponding
|
||||
parenthesized group in the pattern.
|
||||
|
||||
Example:
|
||||
(clojure.string/replace \"Almost Pig Latin\" #\"\\b(\\w)(\\w+)\\b\" \"$2$1ay\")
|
||||
-> \"lmostAay igPay atinLay\""
|
||||
[s match replacement]
|
||||
(cond
|
||||
(string? match)
|
||||
(.replace s (js/RegExp. (gstring/regExpEscape match) "g") replacement)
|
||||
|
||||
(instance? js/RegExp match)
|
||||
(if (string? replacement)
|
||||
(replace-all s match replacement)
|
||||
(replace-all s match (replace-with replacement)))
|
||||
|
||||
:else (throw (str "Invalid match arg: " match))))
|
||||
|
||||
(defn replace-first
|
||||
"Replaces the first instance of match with replacement in s.
|
||||
|
||||
match/replacement can be:
|
||||
|
||||
string / string
|
||||
pattern / (string or function of match).
|
||||
|
||||
See also replace.
|
||||
|
||||
The replacement is literal (i.e. none of its characters are treated
|
||||
specially) for all cases above except pattern / string.
|
||||
|
||||
For pattern / string, $1, $2, etc. in the replacement string are
|
||||
substituted with the string that matched the corresponding
|
||||
parenthesized group in the pattern.
|
||||
|
||||
Example:
|
||||
(clojure.string/replace-first \"swap first two words\"
|
||||
#\"(\\w+)(\\s+)(\\w+)\" \"$3$2$1\")
|
||||
-> \"first swap two words\""
|
||||
[s match replacement]
|
||||
(.replace s match replacement))
|
||||
|
||||
(defn join
|
||||
"Returns a string of all elements in coll, as returned by (seq coll),
|
||||
separated by an optional separator."
|
||||
([coll]
|
||||
(loop [sb (StringBuffer.) coll (seq coll)]
|
||||
(if-not (nil? coll)
|
||||
(recur (. sb (append (str (first coll)))) (next coll))
|
||||
(.toString sb))))
|
||||
([separator coll]
|
||||
(loop [sb (StringBuffer.) coll (seq coll)]
|
||||
(if-not (nil? coll)
|
||||
(do
|
||||
(. sb (append (str (first coll))))
|
||||
(let [coll (next coll)]
|
||||
(when-not (nil? coll)
|
||||
(. sb (append separator)))
|
||||
(recur sb coll)))
|
||||
(.toString sb)))))
|
||||
|
||||
(defn upper-case
|
||||
"Converts string to all upper-case."
|
||||
[s]
|
||||
(.toUpperCase s))
|
||||
|
||||
(defn lower-case
|
||||
"Converts string to all lower-case."
|
||||
[s]
|
||||
(.toLowerCase s))
|
||||
|
||||
(defn capitalize
|
||||
"Converts first character of the string to upper-case, all other
|
||||
characters to lower-case."
|
||||
[s]
|
||||
(gstring/capitalize s))
|
||||
|
||||
;; The JavaScript split function takes a limit argument but the return
|
||||
;; value is not the same as the Java split function.
|
||||
;;
|
||||
;; Java: (.split "a-b-c" #"-" 2) => ["a" "b-c"]
|
||||
;; JavaScript: (.split "a-b-c" #"-" 2) => ["a" "b"]
|
||||
;;
|
||||
;; For consistency, the three arg version has been implemented to
|
||||
;; mimic Java's behavior.
|
||||
|
||||
(defn- pop-last-while-empty
|
||||
[v]
|
||||
(loop [v v]
|
||||
(if (identical? "" (peek v))
|
||||
(recur (pop v))
|
||||
v)))
|
||||
|
||||
(defn- discard-trailing-if-needed
|
||||
[limit v]
|
||||
(if (and (== 0 limit) (< 1 (count v)))
|
||||
(pop-last-while-empty v)
|
||||
v))
|
||||
|
||||
(defn- split-with-empty-regex
|
||||
[s limit]
|
||||
(if (or (<= limit 0) (>= limit (+ 2 (count s))))
|
||||
(conj (vec (cons "" (map str (seq s)))) "")
|
||||
(condp == limit
|
||||
1 (vector s)
|
||||
2 (vector "" s)
|
||||
(let [c (- limit 2)]
|
||||
(conj (vec (cons "" (subvec (vec (map str (seq s))) 0 c))) (subs s c))))))
|
||||
|
||||
(defn split
|
||||
"Splits string on a regular expression. Optional argument limit is
|
||||
the maximum number of splits. Not lazy. Returns vector of the splits."
|
||||
([s re]
|
||||
(split s re 0))
|
||||
([s re limit]
|
||||
(discard-trailing-if-needed limit
|
||||
(if (identical? "/(?:)/" (str re))
|
||||
(split-with-empty-regex s limit)
|
||||
(if (< limit 1)
|
||||
(vec (.split (str s) re))
|
||||
(loop [s s
|
||||
limit limit
|
||||
parts []]
|
||||
(if (== 1 limit)
|
||||
(conj parts s)
|
||||
(let [m (re-find re s)]
|
||||
(if-not (nil? m)
|
||||
(let [index (.indexOf s m)]
|
||||
(recur (.substring s (+ index (count m)))
|
||||
(dec limit)
|
||||
(conj parts (.substring s 0 index))))
|
||||
(conj parts s))))))))))
|
||||
|
||||
(defn split-lines
|
||||
"Splits s on \\n or \\r\\n."
|
||||
[s]
|
||||
(split s #"\n|\r\n"))
|
||||
|
||||
(defn trim
|
||||
"Removes whitespace from both ends of string."
|
||||
[s]
|
||||
(gstring/trim s))
|
||||
|
||||
(defn triml
|
||||
"Removes whitespace from the left side of string."
|
||||
[s]
|
||||
(gstring/trimLeft s))
|
||||
|
||||
(defn trimr
|
||||
"Removes whitespace from the right side of string."
|
||||
[s]
|
||||
(gstring/trimRight s))
|
||||
|
||||
(defn trim-newline
|
||||
"Removes all trailing newline \\n or return \\r characters from
|
||||
string. Similar to Perl's chomp."
|
||||
[s]
|
||||
(loop [index (.-length s)]
|
||||
(if (zero? index)
|
||||
""
|
||||
(let [ch (get s (dec index))]
|
||||
(if (or (identical? \newline ch)
|
||||
(identical? \return ch))
|
||||
(recur (dec index))
|
||||
(.substring s 0 index))))))
|
||||
|
||||
(defn ^boolean blank?
|
||||
"True is s is nil, empty, or contains only whitespace."
|
||||
[s]
|
||||
(gstring/isEmptySafe s))
|
||||
|
||||
(defn escape
|
||||
"Return a new string, using cmap to escape each character ch
|
||||
from s as follows:
|
||||
|
||||
If (cmap ch) is nil, append ch to the new string.
|
||||
If (cmap ch) is non-nil, append (str (cmap ch)) instead."
|
||||
[s cmap]
|
||||
(let [buffer (StringBuffer.)
|
||||
length (.-length s)]
|
||||
(loop [index 0]
|
||||
(if (== length index)
|
||||
(. buffer (toString))
|
||||
(let [ch (.charAt s index)
|
||||
replacement (get cmap ch)]
|
||||
(if-not (nil? replacement)
|
||||
(.append buffer (str replacement))
|
||||
(.append buffer ch))
|
||||
(recur (inc index)))))))
|
||||
|
||||
(defn index-of
|
||||
"Return index of value (string or char) in s, optionally searching
|
||||
forward from from-index or nil if not found."
|
||||
([s value]
|
||||
(let [result (.indexOf s value)]
|
||||
(if (neg? result)
|
||||
nil
|
||||
result)))
|
||||
([s value from-index]
|
||||
(let [result (.indexOf s value from-index)]
|
||||
(if (neg? result)
|
||||
nil
|
||||
result))))
|
||||
|
||||
(defn last-index-of
|
||||
"Return last index of value (string or char) in s, optionally
|
||||
searching backward from from-index or nil if not found."
|
||||
([s value]
|
||||
(let [result (.lastIndexOf s value)]
|
||||
(if (neg? result)
|
||||
nil
|
||||
result)))
|
||||
([s value from-index]
|
||||
(let [result (.lastIndexOf s value from-index)]
|
||||
(if (neg? result)
|
||||
nil
|
||||
result))))
|
||||
|
||||
(defn ^boolean starts-with?
|
||||
"True if s starts with substr."
|
||||
[s substr]
|
||||
(gstring/startsWith s substr))
|
||||
|
||||
(defn ^boolean ends-with?
|
||||
"True if s ends with substr."
|
||||
[s substr]
|
||||
(gstring/endsWith s substr))
|
||||
|
||||
(defn ^boolean includes?
|
||||
"True if s includes substr."
|
||||
[s substr]
|
||||
(gstring/contains s substr))
|
||||
File diff suppressed because one or more lines are too long
477
resources/public/target/cljsbuild-compiler-1/clojure/string.js
Normal file
477
resources/public/target/cljsbuild-compiler-1/clojure/string.js
Normal file
|
|
@ -0,0 +1,477 @@
|
|||
// Compiled by ClojureScript 1.10.520 {}
|
||||
goog.provide('clojure.string');
|
||||
goog.require('cljs.core');
|
||||
goog.require('goog.string');
|
||||
goog.require('goog.string.StringBuffer');
|
||||
clojure.string.seq_reverse = (function clojure$string$seq_reverse(coll){
|
||||
return cljs.core.reduce.call(null,cljs.core.conj,cljs.core.List.EMPTY,coll);
|
||||
});
|
||||
clojure.string.re_surrogate_pair = (new RegExp("([\\uD800-\\uDBFF])([\\uDC00-\\uDFFF])","g"));
|
||||
/**
|
||||
* Returns s with its characters reversed.
|
||||
*/
|
||||
clojure.string.reverse = (function clojure$string$reverse(s){
|
||||
return s.replace(clojure.string.re_surrogate_pair,"$2$1").split("").reverse().join("");
|
||||
});
|
||||
clojure.string.replace_all = (function clojure$string$replace_all(s,re,replacement){
|
||||
var r = (new RegExp(re.source,(function (){var G__21614 = "g";
|
||||
var G__21614__$1 = (cljs.core.truth_(re.ignoreCase)?[G__21614,"i"].join(''):G__21614);
|
||||
var G__21614__$2 = (cljs.core.truth_(re.multiline)?[G__21614__$1,"m"].join(''):G__21614__$1);
|
||||
if(cljs.core.truth_(re.unicode)){
|
||||
return [G__21614__$2,"u"].join('');
|
||||
} else {
|
||||
return G__21614__$2;
|
||||
}
|
||||
})()));
|
||||
return s.replace(r,replacement);
|
||||
});
|
||||
clojure.string.replace_with = (function clojure$string$replace_with(f){
|
||||
return (function() {
|
||||
var G__21615__delegate = function (args){
|
||||
var matches = cljs.core.drop_last.call(null,(2),args);
|
||||
if(cljs.core._EQ_.call(null,cljs.core.count.call(null,matches),(1))){
|
||||
return f.call(null,cljs.core.first.call(null,matches));
|
||||
} else {
|
||||
return f.call(null,cljs.core.vec.call(null,matches));
|
||||
}
|
||||
};
|
||||
var G__21615 = function (var_args){
|
||||
var args = null;
|
||||
if (arguments.length > 0) {
|
||||
var G__21616__i = 0, G__21616__a = new Array(arguments.length - 0);
|
||||
while (G__21616__i < G__21616__a.length) {G__21616__a[G__21616__i] = arguments[G__21616__i + 0]; ++G__21616__i;}
|
||||
args = new cljs.core.IndexedSeq(G__21616__a,0,null);
|
||||
}
|
||||
return G__21615__delegate.call(this,args);};
|
||||
G__21615.cljs$lang$maxFixedArity = 0;
|
||||
G__21615.cljs$lang$applyTo = (function (arglist__21617){
|
||||
var args = cljs.core.seq(arglist__21617);
|
||||
return G__21615__delegate(args);
|
||||
});
|
||||
G__21615.cljs$core$IFn$_invoke$arity$variadic = G__21615__delegate;
|
||||
return G__21615;
|
||||
})()
|
||||
;
|
||||
});
|
||||
/**
|
||||
* Replaces all instance of match with replacement in s.
|
||||
*
|
||||
* match/replacement can be:
|
||||
*
|
||||
* string / string
|
||||
* pattern / (string or function of match).
|
||||
*
|
||||
* See also replace-first.
|
||||
*
|
||||
* The replacement is literal (i.e. none of its characters are treated
|
||||
* specially) for all cases above except pattern / string.
|
||||
*
|
||||
* For pattern / string, $1, $2, etc. in the replacement string are
|
||||
* substituted with the string that matched the corresponding
|
||||
* parenthesized group in the pattern.
|
||||
*
|
||||
* Example:
|
||||
* (clojure.string/replace "Almost Pig Latin" #"\b(\w)(\w+)\b" "$2$1ay")
|
||||
* -> "lmostAay igPay atinLay"
|
||||
*/
|
||||
clojure.string.replace = (function clojure$string$replace(s,match,replacement){
|
||||
if(typeof match === 'string'){
|
||||
return s.replace((new RegExp(goog.string.regExpEscape(match),"g")),replacement);
|
||||
} else {
|
||||
if((match instanceof RegExp)){
|
||||
if(typeof replacement === 'string'){
|
||||
return clojure.string.replace_all.call(null,s,match,replacement);
|
||||
} else {
|
||||
return clojure.string.replace_all.call(null,s,match,clojure.string.replace_with.call(null,replacement));
|
||||
}
|
||||
} else {
|
||||
throw ["Invalid match arg: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(match)].join('');
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
/**
|
||||
* Replaces the first instance of match with replacement in s.
|
||||
*
|
||||
* match/replacement can be:
|
||||
*
|
||||
* string / string
|
||||
* pattern / (string or function of match).
|
||||
*
|
||||
* See also replace.
|
||||
*
|
||||
* The replacement is literal (i.e. none of its characters are treated
|
||||
* specially) for all cases above except pattern / string.
|
||||
*
|
||||
* For pattern / string, $1, $2, etc. in the replacement string are
|
||||
* substituted with the string that matched the corresponding
|
||||
* parenthesized group in the pattern.
|
||||
*
|
||||
* Example:
|
||||
* (clojure.string/replace-first "swap first two words"
|
||||
* #"(\w+)(\s+)(\w+)" "$3$2$1")
|
||||
* -> "first swap two words"
|
||||
*/
|
||||
clojure.string.replace_first = (function clojure$string$replace_first(s,match,replacement){
|
||||
return s.replace(match,replacement);
|
||||
});
|
||||
/**
|
||||
* Returns a string of all elements in coll, as returned by (seq coll),
|
||||
* separated by an optional separator.
|
||||
*/
|
||||
clojure.string.join = (function clojure$string$join(var_args){
|
||||
var G__21619 = arguments.length;
|
||||
switch (G__21619) {
|
||||
case 1:
|
||||
return clojure.string.join.cljs$core$IFn$_invoke$arity$1((arguments[(0)]));
|
||||
|
||||
break;
|
||||
case 2:
|
||||
return clojure.string.join.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)]));
|
||||
|
||||
break;
|
||||
default:
|
||||
throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
clojure.string.join.cljs$core$IFn$_invoke$arity$1 = (function (coll){
|
||||
var sb = (new goog.string.StringBuffer());
|
||||
var coll__$1 = cljs.core.seq.call(null,coll);
|
||||
while(true){
|
||||
if((!((coll__$1 == null)))){
|
||||
var G__21621 = sb.append(cljs.core.str.cljs$core$IFn$_invoke$arity$1(cljs.core.first.call(null,coll__$1)));
|
||||
var G__21622 = cljs.core.next.call(null,coll__$1);
|
||||
sb = G__21621;
|
||||
coll__$1 = G__21622;
|
||||
continue;
|
||||
} else {
|
||||
return sb.toString();
|
||||
}
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
clojure.string.join.cljs$core$IFn$_invoke$arity$2 = (function (separator,coll){
|
||||
var sb = (new goog.string.StringBuffer());
|
||||
var coll__$1 = cljs.core.seq.call(null,coll);
|
||||
while(true){
|
||||
if((!((coll__$1 == null)))){
|
||||
sb.append(cljs.core.str.cljs$core$IFn$_invoke$arity$1(cljs.core.first.call(null,coll__$1)));
|
||||
|
||||
var coll__$2 = cljs.core.next.call(null,coll__$1);
|
||||
if((coll__$2 == null)){
|
||||
} else {
|
||||
sb.append(separator);
|
||||
}
|
||||
|
||||
var G__21623 = sb;
|
||||
var G__21624 = coll__$2;
|
||||
sb = G__21623;
|
||||
coll__$1 = G__21624;
|
||||
continue;
|
||||
} else {
|
||||
return sb.toString();
|
||||
}
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
clojure.string.join.cljs$lang$maxFixedArity = 2;
|
||||
|
||||
/**
|
||||
* Converts string to all upper-case.
|
||||
*/
|
||||
clojure.string.upper_case = (function clojure$string$upper_case(s){
|
||||
return s.toUpperCase();
|
||||
});
|
||||
/**
|
||||
* Converts string to all lower-case.
|
||||
*/
|
||||
clojure.string.lower_case = (function clojure$string$lower_case(s){
|
||||
return s.toLowerCase();
|
||||
});
|
||||
/**
|
||||
* Converts first character of the string to upper-case, all other
|
||||
* characters to lower-case.
|
||||
*/
|
||||
clojure.string.capitalize = (function clojure$string$capitalize(s){
|
||||
return goog.string.capitalize(s);
|
||||
});
|
||||
clojure.string.pop_last_while_empty = (function clojure$string$pop_last_while_empty(v){
|
||||
var v__$1 = v;
|
||||
while(true){
|
||||
if(("" === cljs.core.peek.call(null,v__$1))){
|
||||
var G__21625 = cljs.core.pop.call(null,v__$1);
|
||||
v__$1 = G__21625;
|
||||
continue;
|
||||
} else {
|
||||
return v__$1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
});
|
||||
clojure.string.discard_trailing_if_needed = (function clojure$string$discard_trailing_if_needed(limit,v){
|
||||
if(((((0) === limit)) && (((1) < cljs.core.count.call(null,v))))){
|
||||
return clojure.string.pop_last_while_empty.call(null,v);
|
||||
} else {
|
||||
return v;
|
||||
}
|
||||
});
|
||||
clojure.string.split_with_empty_regex = (function clojure$string$split_with_empty_regex(s,limit){
|
||||
if((((limit <= (0))) || ((limit >= ((2) + cljs.core.count.call(null,s)))))){
|
||||
return cljs.core.conj.call(null,cljs.core.vec.call(null,cljs.core.cons.call(null,"",cljs.core.map.call(null,cljs.core.str,cljs.core.seq.call(null,s)))),"");
|
||||
} else {
|
||||
var pred__21626 = cljs.core._EQ__EQ_;
|
||||
var expr__21627 = limit;
|
||||
if(cljs.core.truth_(pred__21626.call(null,(1),expr__21627))){
|
||||
return (new cljs.core.PersistentVector(null,1,(5),cljs.core.PersistentVector.EMPTY_NODE,[s],null));
|
||||
} else {
|
||||
if(cljs.core.truth_(pred__21626.call(null,(2),expr__21627))){
|
||||
return (new cljs.core.PersistentVector(null,2,(5),cljs.core.PersistentVector.EMPTY_NODE,["",s],null));
|
||||
} else {
|
||||
var c = (limit - (2));
|
||||
return cljs.core.conj.call(null,cljs.core.vec.call(null,cljs.core.cons.call(null,"",cljs.core.subvec.call(null,cljs.core.vec.call(null,cljs.core.map.call(null,cljs.core.str,cljs.core.seq.call(null,s))),(0),c))),cljs.core.subs.call(null,s,c));
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
/**
|
||||
* Splits string on a regular expression. Optional argument limit is
|
||||
* the maximum number of splits. Not lazy. Returns vector of the splits.
|
||||
*/
|
||||
clojure.string.split = (function clojure$string$split(var_args){
|
||||
var G__21630 = arguments.length;
|
||||
switch (G__21630) {
|
||||
case 2:
|
||||
return clojure.string.split.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)]));
|
||||
|
||||
break;
|
||||
case 3:
|
||||
return clojure.string.split.cljs$core$IFn$_invoke$arity$3((arguments[(0)]),(arguments[(1)]),(arguments[(2)]));
|
||||
|
||||
break;
|
||||
default:
|
||||
throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
clojure.string.split.cljs$core$IFn$_invoke$arity$2 = (function (s,re){
|
||||
return clojure.string.split.call(null,s,re,(0));
|
||||
});
|
||||
|
||||
clojure.string.split.cljs$core$IFn$_invoke$arity$3 = (function (s,re,limit){
|
||||
return clojure.string.discard_trailing_if_needed.call(null,limit,((("/(?:)/" === cljs.core.str.cljs$core$IFn$_invoke$arity$1(re)))?clojure.string.split_with_empty_regex.call(null,s,limit):(((limit < (1)))?cljs.core.vec.call(null,cljs.core.str.cljs$core$IFn$_invoke$arity$1(s).split(re)):(function (){var s__$1 = s;
|
||||
var limit__$1 = limit;
|
||||
var parts = cljs.core.PersistentVector.EMPTY;
|
||||
while(true){
|
||||
if(((1) === limit__$1)){
|
||||
return cljs.core.conj.call(null,parts,s__$1);
|
||||
} else {
|
||||
var m = cljs.core.re_find.call(null,re,s__$1);
|
||||
if((!((m == null)))){
|
||||
var index = s__$1.indexOf(m);
|
||||
var G__21632 = s__$1.substring((index + cljs.core.count.call(null,m)));
|
||||
var G__21633 = (limit__$1 - (1));
|
||||
var G__21634 = cljs.core.conj.call(null,parts,s__$1.substring((0),index));
|
||||
s__$1 = G__21632;
|
||||
limit__$1 = G__21633;
|
||||
parts = G__21634;
|
||||
continue;
|
||||
} else {
|
||||
return cljs.core.conj.call(null,parts,s__$1);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
})())));
|
||||
});
|
||||
|
||||
clojure.string.split.cljs$lang$maxFixedArity = 3;
|
||||
|
||||
/**
|
||||
* Splits s on \n or \r\n.
|
||||
*/
|
||||
clojure.string.split_lines = (function clojure$string$split_lines(s){
|
||||
return clojure.string.split.call(null,s,/\n|\r\n/);
|
||||
});
|
||||
/**
|
||||
* Removes whitespace from both ends of string.
|
||||
*/
|
||||
clojure.string.trim = (function clojure$string$trim(s){
|
||||
return goog.string.trim(s);
|
||||
});
|
||||
/**
|
||||
* Removes whitespace from the left side of string.
|
||||
*/
|
||||
clojure.string.triml = (function clojure$string$triml(s){
|
||||
return goog.string.trimLeft(s);
|
||||
});
|
||||
/**
|
||||
* Removes whitespace from the right side of string.
|
||||
*/
|
||||
clojure.string.trimr = (function clojure$string$trimr(s){
|
||||
return goog.string.trimRight(s);
|
||||
});
|
||||
/**
|
||||
* Removes all trailing newline \n or return \r characters from
|
||||
* string. Similar to Perl's chomp.
|
||||
*/
|
||||
clojure.string.trim_newline = (function clojure$string$trim_newline(s){
|
||||
var index = s.length;
|
||||
while(true){
|
||||
if((index === (0))){
|
||||
return "";
|
||||
} else {
|
||||
var ch = cljs.core.get.call(null,s,(index - (1)));
|
||||
if(((("\n" === ch)) || (("\r" === ch)))){
|
||||
var G__21635 = (index - (1));
|
||||
index = G__21635;
|
||||
continue;
|
||||
} else {
|
||||
return s.substring((0),index);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
});
|
||||
/**
|
||||
* True is s is nil, empty, or contains only whitespace.
|
||||
*/
|
||||
clojure.string.blank_QMARK_ = (function clojure$string$blank_QMARK_(s){
|
||||
return goog.string.isEmptySafe(s);
|
||||
});
|
||||
/**
|
||||
* Return a new string, using cmap to escape each character ch
|
||||
* from s as follows:
|
||||
*
|
||||
* If (cmap ch) is nil, append ch to the new string.
|
||||
* If (cmap ch) is non-nil, append (str (cmap ch)) instead.
|
||||
*/
|
||||
clojure.string.escape = (function clojure$string$escape(s,cmap){
|
||||
var buffer = (new goog.string.StringBuffer());
|
||||
var length = s.length;
|
||||
var index = (0);
|
||||
while(true){
|
||||
if((length === index)){
|
||||
return buffer.toString();
|
||||
} else {
|
||||
var ch = s.charAt(index);
|
||||
var replacement = cljs.core.get.call(null,cmap,ch);
|
||||
if((!((replacement == null)))){
|
||||
buffer.append(cljs.core.str.cljs$core$IFn$_invoke$arity$1(replacement));
|
||||
} else {
|
||||
buffer.append(ch);
|
||||
}
|
||||
|
||||
var G__21636 = (index + (1));
|
||||
index = G__21636;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
});
|
||||
/**
|
||||
* Return index of value (string or char) in s, optionally searching
|
||||
* forward from from-index or nil if not found.
|
||||
*/
|
||||
clojure.string.index_of = (function clojure$string$index_of(var_args){
|
||||
var G__21638 = arguments.length;
|
||||
switch (G__21638) {
|
||||
case 2:
|
||||
return clojure.string.index_of.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)]));
|
||||
|
||||
break;
|
||||
case 3:
|
||||
return clojure.string.index_of.cljs$core$IFn$_invoke$arity$3((arguments[(0)]),(arguments[(1)]),(arguments[(2)]));
|
||||
|
||||
break;
|
||||
default:
|
||||
throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
clojure.string.index_of.cljs$core$IFn$_invoke$arity$2 = (function (s,value){
|
||||
var result = s.indexOf(value);
|
||||
if((result < (0))){
|
||||
return null;
|
||||
} else {
|
||||
return result;
|
||||
}
|
||||
});
|
||||
|
||||
clojure.string.index_of.cljs$core$IFn$_invoke$arity$3 = (function (s,value,from_index){
|
||||
var result = s.indexOf(value,from_index);
|
||||
if((result < (0))){
|
||||
return null;
|
||||
} else {
|
||||
return result;
|
||||
}
|
||||
});
|
||||
|
||||
clojure.string.index_of.cljs$lang$maxFixedArity = 3;
|
||||
|
||||
/**
|
||||
* Return last index of value (string or char) in s, optionally
|
||||
* searching backward from from-index or nil if not found.
|
||||
*/
|
||||
clojure.string.last_index_of = (function clojure$string$last_index_of(var_args){
|
||||
var G__21641 = arguments.length;
|
||||
switch (G__21641) {
|
||||
case 2:
|
||||
return clojure.string.last_index_of.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)]));
|
||||
|
||||
break;
|
||||
case 3:
|
||||
return clojure.string.last_index_of.cljs$core$IFn$_invoke$arity$3((arguments[(0)]),(arguments[(1)]),(arguments[(2)]));
|
||||
|
||||
break;
|
||||
default:
|
||||
throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
clojure.string.last_index_of.cljs$core$IFn$_invoke$arity$2 = (function (s,value){
|
||||
var result = s.lastIndexOf(value);
|
||||
if((result < (0))){
|
||||
return null;
|
||||
} else {
|
||||
return result;
|
||||
}
|
||||
});
|
||||
|
||||
clojure.string.last_index_of.cljs$core$IFn$_invoke$arity$3 = (function (s,value,from_index){
|
||||
var result = s.lastIndexOf(value,from_index);
|
||||
if((result < (0))){
|
||||
return null;
|
||||
} else {
|
||||
return result;
|
||||
}
|
||||
});
|
||||
|
||||
clojure.string.last_index_of.cljs$lang$maxFixedArity = 3;
|
||||
|
||||
/**
|
||||
* True if s starts with substr.
|
||||
*/
|
||||
clojure.string.starts_with_QMARK_ = (function clojure$string$starts_with_QMARK_(s,substr){
|
||||
return goog.string.startsWith(s,substr);
|
||||
});
|
||||
/**
|
||||
* True if s ends with substr.
|
||||
*/
|
||||
clojure.string.ends_with_QMARK_ = (function clojure$string$ends_with_QMARK_(s,substr){
|
||||
return goog.string.endsWith(s,substr);
|
||||
});
|
||||
/**
|
||||
* True if s includes substr.
|
||||
*/
|
||||
clojure.string.includes_QMARK_ = (function clojure$string$includes_QMARK_(s,substr){
|
||||
return goog.string.contains(s,substr);
|
||||
});
|
||||
|
||||
//# sourceMappingURL=string.js.map
|
||||
File diff suppressed because one or more lines are too long
|
|
@ -0,0 +1,413 @@
|
|||
;; Copyright 2014-2018 Cognitect. All Rights Reserved.
|
||||
;;
|
||||
;; Licensed under the Apache License, Version 2.0 (the "License");
|
||||
;; you may not use this file except in compliance with the License.
|
||||
;; You may obtain a copy of the License at
|
||||
;;
|
||||
;; http://www.apache.org/licenses/LICENSE-2.0
|
||||
;;
|
||||
;; Unless required by applicable law or agreed to in writing, software
|
||||
;; distributed under the License is distributed on an "AS-IS" BASIS,
|
||||
;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
;; See the License for the specific language governing permissions and
|
||||
;; limitations under the License.
|
||||
|
||||
(ns cognitect.transit
|
||||
(:refer-clojure :exclude [integer? uuid uuid? uri?])
|
||||
(:require [com.cognitect.transit :as t]
|
||||
[com.cognitect.transit.types :as ty]
|
||||
[com.cognitect.transit.eq :as eq])
|
||||
(:import [goog.math Long]))
|
||||
|
||||
;; patch cljs.core/UUID IEquiv
|
||||
|
||||
(extend-type UUID
|
||||
IEquiv
|
||||
(-equiv [this other]
|
||||
(cond
|
||||
(instance? UUID other)
|
||||
(identical? (.-uuid this) (.-uuid other))
|
||||
|
||||
(instance? ty/UUID other)
|
||||
(identical? (.-uuid this) (.toString other))
|
||||
|
||||
:else false)))
|
||||
|
||||
(extend-protocol IComparable
|
||||
UUID
|
||||
(-compare [this other]
|
||||
(if (or (instance? UUID other)
|
||||
(instance? ty/UUID other))
|
||||
(compare (.toString this) (.toString other))
|
||||
(throw (js/Error. (str "Cannot compare " this " to " other)))))
|
||||
ty/UUID
|
||||
(-compare [this other]
|
||||
(if (or (instance? UUID other)
|
||||
(instance? ty/UUID other))
|
||||
(compare (.toString this) (.toString other))
|
||||
(throw (js/Error. (str "Cannot compare " this " to " other))))))
|
||||
|
||||
(extend-protocol IEquiv
|
||||
Long
|
||||
(-equiv [this other]
|
||||
(.equiv this other))
|
||||
|
||||
ty/UUID
|
||||
(-equiv [this other]
|
||||
(if (instance? UUID other)
|
||||
(-equiv other this)
|
||||
(.equiv this other)))
|
||||
|
||||
ty/TaggedValue
|
||||
(-equiv [this other]
|
||||
(.equiv this other)))
|
||||
|
||||
(extend-protocol IHash
|
||||
Long
|
||||
(-hash [this]
|
||||
(eq/hashCode this))
|
||||
|
||||
ty/UUID
|
||||
(-hash [this]
|
||||
(hash (.toString this)))
|
||||
|
||||
ty/TaggedValue
|
||||
(-hash [this]
|
||||
(eq/hashCode this)))
|
||||
|
||||
(extend-type ty/UUID
|
||||
IPrintWithWriter
|
||||
(-pr-writer [uuid writer _]
|
||||
(-write writer (str "#uuid \"" (.toString uuid) "\""))))
|
||||
|
||||
(defn ^:no-doc opts-merge [a b]
|
||||
(doseq [k (js-keys b)]
|
||||
(let [v (aget b k)]
|
||||
(aset a k v)))
|
||||
a)
|
||||
|
||||
(deftype ^:no-doc MapBuilder []
|
||||
Object
|
||||
(init [_ node] (transient {}))
|
||||
(add [_ m k v node] (assoc! m k v))
|
||||
(finalize [_ m node] (persistent! m))
|
||||
(fromArray [_ arr node] (cljs.core/PersistentArrayMap.fromArray arr true true)))
|
||||
|
||||
(deftype ^:no-doc VectorBuilder []
|
||||
Object
|
||||
(init [_ node] (transient []))
|
||||
(add [_ v x node] (conj! v x))
|
||||
(finalize [_ v node] (persistent! v))
|
||||
(fromArray [_ arr node] (cljs.core/PersistentVector.fromArray arr true)))
|
||||
|
||||
(defn reader
|
||||
"Return a transit reader. type may be either :json or :json-verbose.
|
||||
opts may be a map optionally containing a :handlers entry. The value
|
||||
of :handlers should be map from tag to a decoder function which returns
|
||||
then in-memory representation of the semantic transit value."
|
||||
([type] (reader type nil))
|
||||
([type opts]
|
||||
(t/reader (name type)
|
||||
(opts-merge
|
||||
#js {:handlers
|
||||
(clj->js
|
||||
(merge
|
||||
{"$" (fn [v] (symbol v))
|
||||
":" (fn [v] (keyword v))
|
||||
"set" (fn [v] (into #{} v))
|
||||
"list" (fn [v] (into () (.reverse v)))
|
||||
"cmap" (fn [v]
|
||||
(loop [i 0 ret (transient {})]
|
||||
(if (< i (alength v))
|
||||
(recur (+ i 2)
|
||||
(assoc! ret (aget v i) (aget v (inc i))))
|
||||
(persistent! ret))))
|
||||
"with-meta"
|
||||
(fn [v] (with-meta (aget v 0) (aget v 1)))}
|
||||
(:handlers opts)))
|
||||
:mapBuilder (MapBuilder.)
|
||||
:arrayBuilder (VectorBuilder.)
|
||||
:prefersStrings false}
|
||||
(clj->js (dissoc opts :handlers))))))
|
||||
|
||||
(defn read
|
||||
"Read a transit encoded string into ClojureScript values given a
|
||||
transit reader."
|
||||
[r str]
|
||||
(.read r str))
|
||||
|
||||
(deftype ^:no-doc KeywordHandler []
|
||||
Object
|
||||
(tag [_ v] ":")
|
||||
(rep [_ v] (.-fqn v))
|
||||
(stringRep [_ v] (.-fqn v)))
|
||||
|
||||
(deftype ^:no-doc SymbolHandler []
|
||||
Object
|
||||
(tag [_ v] "$")
|
||||
(rep [_ v] (.-str v))
|
||||
(stringRep [_ v] (.-str v)))
|
||||
|
||||
(deftype ^:no-doc ListHandler []
|
||||
Object
|
||||
(tag [_ v] "list")
|
||||
(rep [_ v]
|
||||
(let [ret #js []]
|
||||
(doseq [x v] (.push ret x))
|
||||
(t/tagged "array" ret)))
|
||||
(stringRep [_ v] nil))
|
||||
|
||||
(deftype ^:no-doc MapHandler []
|
||||
Object
|
||||
(tag [_ v] "map")
|
||||
(rep [_ v] v)
|
||||
(stringRep [_ v] nil))
|
||||
|
||||
(deftype ^:no-doc SetHandler []
|
||||
Object
|
||||
(tag [_ v] "set")
|
||||
(rep [_ v]
|
||||
(let [ret #js []]
|
||||
(doseq [x v] (.push ret x))
|
||||
(t/tagged "array" ret)))
|
||||
(stringRep [v] nil))
|
||||
|
||||
(deftype ^:no-doc VectorHandler []
|
||||
Object
|
||||
(tag [_ v] "array")
|
||||
(rep [_ v]
|
||||
(let [ret #js []]
|
||||
(doseq [x v] (.push ret x))
|
||||
ret))
|
||||
(stringRep [_ v] nil))
|
||||
|
||||
(deftype ^:no-doc UUIDHandler []
|
||||
Object
|
||||
(tag [_ v] "u")
|
||||
(rep [_ v] (.-uuid v))
|
||||
(stringRep [this v] (.rep this v)))
|
||||
|
||||
(deftype ^:no-doc WithMeta [value meta])
|
||||
|
||||
(deftype ^:no-doc WithMetaHandler []
|
||||
Object
|
||||
(tag [_ v] "with-meta")
|
||||
(rep [_ v]
|
||||
(t/tagged "array" #js [(.-value v) (.-meta v)]))
|
||||
(stringRep [_ v] nil))
|
||||
|
||||
(defn writer
|
||||
"Return a transit writer. type maybe either :json or :json-verbose.
|
||||
opts is a map with the following optional keys:
|
||||
|
||||
:handlers - a map of type constructors to handler instances.
|
||||
:transform - a function of one argument returning a transformed value. Will
|
||||
be invoked on a value before it is written."
|
||||
([type] (writer type nil))
|
||||
([type opts]
|
||||
(let [keyword-handler (KeywordHandler.)
|
||||
symbol-handler (SymbolHandler.)
|
||||
list-handler (ListHandler.)
|
||||
map-handler (MapHandler.)
|
||||
set-handler (SetHandler.)
|
||||
vector-handler (VectorHandler.)
|
||||
uuid-handler (UUIDHandler.)
|
||||
meta-handler (WithMetaHandler.)
|
||||
handlers
|
||||
(merge
|
||||
{cljs.core/Keyword keyword-handler
|
||||
cljs.core/Symbol symbol-handler
|
||||
cljs.core/Range list-handler
|
||||
cljs.core/List list-handler
|
||||
cljs.core/Cons list-handler
|
||||
cljs.core/EmptyList list-handler
|
||||
cljs.core/LazySeq list-handler
|
||||
cljs.core/RSeq list-handler
|
||||
cljs.core/IndexedSeq list-handler
|
||||
cljs.core/ChunkedCons list-handler
|
||||
cljs.core/ChunkedSeq list-handler
|
||||
cljs.core/PersistentQueueSeq list-handler
|
||||
cljs.core/PersistentQueue list-handler
|
||||
cljs.core/PersistentArrayMapSeq list-handler
|
||||
cljs.core/PersistentTreeMapSeq list-handler
|
||||
cljs.core/NodeSeq list-handler
|
||||
cljs.core/ArrayNodeSeq list-handler
|
||||
cljs.core/KeySeq list-handler
|
||||
cljs.core/ValSeq list-handler
|
||||
cljs.core/PersistentArrayMap map-handler
|
||||
cljs.core/PersistentHashMap map-handler
|
||||
cljs.core/PersistentTreeMap map-handler
|
||||
cljs.core/PersistentHashSet set-handler
|
||||
cljs.core/PersistentTreeSet set-handler
|
||||
cljs.core/PersistentVector vector-handler
|
||||
cljs.core/Subvec vector-handler
|
||||
cljs.core/UUID uuid-handler
|
||||
WithMeta meta-handler}
|
||||
(when (exists? cljs.core/Eduction)
|
||||
{^:cljs.analyzer/no-resolve cljs.core/Eduction list-handler})
|
||||
(when (exists? cljs.core/Repeat)
|
||||
{^:cljs.analyzer/no-resolve cljs.core/Repeat list-handler})
|
||||
(when (exists? cljs.core/MapEntry)
|
||||
{^:cljs.analyzer/no-resolve cljs.core/MapEntry vector-handler})
|
||||
(:handlers opts))]
|
||||
(t/writer (name type)
|
||||
(opts-merge
|
||||
#js {:objectBuilder
|
||||
(fn [m kfn vfn]
|
||||
(reduce-kv
|
||||
(fn [obj k v]
|
||||
(doto obj (.push (kfn k) (vfn v))))
|
||||
#js ["^ "] m))
|
||||
:handlers
|
||||
(specify handlers
|
||||
Object
|
||||
(forEach
|
||||
([coll f]
|
||||
(doseq [[k v] coll]
|
||||
(f v k)))))
|
||||
:unpack
|
||||
(fn [x]
|
||||
(if (instance? cljs.core/PersistentArrayMap x)
|
||||
(.-arr x)
|
||||
false))}
|
||||
(clj->js (dissoc opts :handlers)))))))
|
||||
|
||||
(defn write
|
||||
"Encode an object into a transit string given a transit writer."
|
||||
[w o]
|
||||
(.write w o))
|
||||
|
||||
(defn read-handler
|
||||
"Construct a read handler. Implemented as identity, exists primarily
|
||||
for API compatiblity with transit-clj"
|
||||
[from-rep]
|
||||
from-rep)
|
||||
|
||||
(defn write-handler
|
||||
"Creates a transit write handler whose tag, rep,
|
||||
stringRep, and verboseWriteHandler methods
|
||||
invoke the provided fns."
|
||||
([tag-fn rep-fn]
|
||||
(write-handler tag-fn rep-fn nil nil))
|
||||
([tag-fn rep-fn str-rep-fn]
|
||||
(write-handler tag-fn rep-fn str-rep-fn nil))
|
||||
([tag-fn rep-fn str-rep-fn verbose-handler-fn]
|
||||
(reify
|
||||
Object
|
||||
(tag [_ o] (tag-fn o))
|
||||
(rep [_ o] (rep-fn o))
|
||||
(stringRep [_ o] (when str-rep-fn (str-rep-fn o)))
|
||||
(getVerboseHandler [_] (when verbose-handler-fn (verbose-handler-fn))))))
|
||||
|
||||
;; =============================================================================
|
||||
;; Constructors & Predicates
|
||||
|
||||
(defn tagged-value
|
||||
"Construct a tagged value. tag must be a string and rep can
|
||||
be any transit encodeable value."
|
||||
[tag rep]
|
||||
(ty/taggedValue tag rep))
|
||||
|
||||
(defn tagged-value?
|
||||
"Returns true if x is a transit tagged value, false otherwise."
|
||||
[x]
|
||||
(ty/isTaggedValue x))
|
||||
|
||||
(defn integer
|
||||
"Construct a transit integer value. Returns JavaScript number if
|
||||
in the 53bit integer range, a goog.math.Long instance if above. s
|
||||
may be a string or a JavaScript number."
|
||||
[s]
|
||||
(ty/intValue s))
|
||||
|
||||
(defn integer?
|
||||
"Returns true if x is an integer value between the 53bit and 64bit
|
||||
range, false otherwise."
|
||||
[x]
|
||||
(ty/isInteger x))
|
||||
|
||||
(defn bigint
|
||||
"Construct a big integer from a string."
|
||||
[s]
|
||||
(ty/bigInteger s))
|
||||
|
||||
(defn bigint?
|
||||
"Returns true if x is a transit big integer value, false otherwise."
|
||||
[x]
|
||||
(ty/isBigInteger x))
|
||||
|
||||
(defn bigdec
|
||||
"Construct a big decimal from a string."
|
||||
[s]
|
||||
(ty/bigDecimalValue s))
|
||||
|
||||
(defn bigdec?
|
||||
"Returns true if x is a transit big decimal value, false otherwise."
|
||||
[x]
|
||||
(ty/isBigDecimal x))
|
||||
|
||||
(defn uri
|
||||
"Construct a URI from a string."
|
||||
[s]
|
||||
(ty/uri s))
|
||||
|
||||
(defn uri?
|
||||
"Returns true if x is a transit URI value, false otherwise."
|
||||
[x]
|
||||
(ty/isURI x))
|
||||
|
||||
(defn uuid
|
||||
"Construct a UUID from a string."
|
||||
[s]
|
||||
(ty/uuid s))
|
||||
|
||||
(defn uuid?
|
||||
"Returns true if x is a transit UUID value, false otherwise."
|
||||
[x]
|
||||
(or (ty/isUUID x) (instance? UUID x)))
|
||||
|
||||
(defn binary
|
||||
"Construct a transit binary value. s should be base64 encoded
|
||||
string."
|
||||
[s]
|
||||
(ty/binary s))
|
||||
|
||||
(defn binary?
|
||||
"Returns true if x is a transit binary value, false otherwise."
|
||||
[x]
|
||||
(ty/isBinary x))
|
||||
|
||||
(defn quoted
|
||||
"Construct a quoted transit value. x should be a transit
|
||||
encodeable value."
|
||||
[x]
|
||||
(ty/quoted x))
|
||||
|
||||
(defn quoted?
|
||||
"Returns true if x is a transit quoted value, false otherwise."
|
||||
[x]
|
||||
(ty/isQuoted x))
|
||||
|
||||
(defn link
|
||||
"Construct a transit link value. x should be an IMap instance
|
||||
containing at a minimum the following keys: :href, :rel. It
|
||||
may optionall include :name, :render, and :prompt. :href must
|
||||
be a transit URI, all other values are strings, and :render must
|
||||
be either :image or :link."
|
||||
[x]
|
||||
(ty/link x))
|
||||
|
||||
(defn link?
|
||||
"Returns true if x a transit link value, false if otherwise."
|
||||
[x]
|
||||
(ty/isLink x))
|
||||
|
||||
(defn write-meta
|
||||
"For :transform. Will write any metadata present on the value."
|
||||
[x]
|
||||
(if (implements? IMeta x)
|
||||
(let [m (-meta ^not-native x)]
|
||||
(if-not (nil? m)
|
||||
(WithMeta. (-with-meta ^not-native x nil) m)
|
||||
x))
|
||||
x))
|
||||
File diff suppressed because one or more lines are too long
1272
resources/public/target/cljsbuild-compiler-1/cognitect/transit.js
Normal file
1272
resources/public/target/cljsbuild-compiler-1/cognitect/transit.js
Normal file
File diff suppressed because it is too large
Load diff
File diff suppressed because one or more lines are too long
|
|
@ -0,0 +1,698 @@
|
|||
// Copyright 2014 Cognitect. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS-IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
"use strict";
|
||||
|
||||
goog.provide("com.cognitect.transit");
|
||||
goog.require("com.cognitect.transit.util");
|
||||
goog.require("com.cognitect.transit.impl.reader");
|
||||
goog.require("com.cognitect.transit.impl.writer");
|
||||
goog.require("com.cognitect.transit.types");
|
||||
goog.require("com.cognitect.transit.eq");
|
||||
goog.require("com.cognitect.transit.impl.decoder");
|
||||
goog.require("com.cognitect.transit.caching");
|
||||
|
||||
/** @define {boolean} */
|
||||
var TRANSIT_DEV = true;
|
||||
|
||||
/** @define {boolean} */
|
||||
var TRANSIT_NODE_TARGET = false;
|
||||
|
||||
/** @define {boolean} */
|
||||
var TRANSIT_BROWSER_TARGET = false;
|
||||
|
||||
/** @define {boolean} */
|
||||
var TRANSIT_BROWSER_AMD_TARGET = false;
|
||||
|
||||
goog.scope(function() {
|
||||
|
||||
/**
|
||||
* @class transit
|
||||
*/
|
||||
var transit = com.cognitect.transit;
|
||||
|
||||
var util = com.cognitect.transit.util,
|
||||
reader = com.cognitect.transit.impl.reader,
|
||||
writer = com.cognitect.transit.impl.writer,
|
||||
decoder = com.cognitect.transit.impl.decoder,
|
||||
types = com.cognitect.transit.types,
|
||||
eq = com.cognitect.transit.eq,
|
||||
caching = com.cognitect.transit.caching;
|
||||
|
||||
/**
|
||||
* @typedef {Map|com.cognitect.transit.types.TransitArrayMap|com.cognitect.transit.types.TransitMap}
|
||||
*/
|
||||
transit.MapLike;
|
||||
|
||||
/**
|
||||
* @typedef {Set|com.cognitect.transit.types.TransitSet}
|
||||
*/
|
||||
transit.SetLike;
|
||||
|
||||
/**
|
||||
* Create a transit reader instance.
|
||||
* @method transit.reader
|
||||
* @param {string=} type
|
||||
* type of reader to construct. Default to "json". For verbose mode
|
||||
* supply "json-verbose".
|
||||
* @param {Object=} opts
|
||||
* reader options. A JavaScript object to customize the writer Valid
|
||||
* entries include "defaultHandler", and "handler". "defaultHandler"
|
||||
* should be JavaScript function taking two arguments, the first is the
|
||||
* tag, the second the value. "handlers" should be an object of tags to
|
||||
* handle. The values are functions that will receive the value of matched
|
||||
* tag. "preferBuffers" may be supplied to customize binary
|
||||
* decoding. If available binary data will read as Node.js Buffers,
|
||||
* If Buffer is not available or "prefersBuffers" is set to false
|
||||
* data will be read as Uint8Array. If neither Buffer nor Uint8Array is
|
||||
* available - defaults to tagged value that simply wraps the
|
||||
* base64 encoded string.
|
||||
* @return {com.cognitect.transit.impl.reader.Reader} A transit reader.
|
||||
* @example
|
||||
* var r = transit.reader("json", {
|
||||
* handlers: {
|
||||
* "point": function(v) { return new Point(v[0], v[1]); }
|
||||
* }
|
||||
* });
|
||||
*/
|
||||
transit.reader = function(type, opts) {
|
||||
if(type === "json" || type === "json-verbose" || type == null) {
|
||||
type = "json";
|
||||
var unmarshaller = new reader.JSONUnmarshaller(opts);
|
||||
return new reader.Reader(unmarshaller, opts);
|
||||
} else {
|
||||
throw new Error("Cannot create reader of type " + type);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Create a transit writer instance.
|
||||
* @method transit.writer
|
||||
* @param {string=} type
|
||||
* type of writer to construct. Defaults to "json". For verbose mode
|
||||
* supply "json-verbose".
|
||||
* @param {Object=} opts
|
||||
* writer options. A JavaScript object to customize the writer.
|
||||
* "handlers" options, a transit.map of JavaScript constructor and
|
||||
* transit writer handler instance entries. "handlerForForeign" option,
|
||||
* for dealing with values from other JavaScript contexts. This function
|
||||
* will be passed the unmatchable value and the installed handlers. The
|
||||
* function should return the correct handler. Note if this function is
|
||||
* provided, special handling for Objects will also be
|
||||
* auto-installed to catch plain Objects from the foreign context.
|
||||
* @return {com.cognitect.transit.impl.writer.Writer} A transit writer.
|
||||
* @example
|
||||
* var r = transit.writer("json", {
|
||||
* handlers: transit.map([
|
||||
* Point, PointHandler
|
||||
* ])
|
||||
* });
|
||||
*/
|
||||
transit.writer = function(type, opts) {
|
||||
if(type === "json" || type === "json-verbose" || type == null) {
|
||||
if(type === "json-verbose") {
|
||||
if(opts == null) opts = {};
|
||||
opts["verbose"] = true;
|
||||
}
|
||||
var marshaller = new writer.JSONMarshaller(opts);
|
||||
return new writer.Writer(marshaller, opts);
|
||||
} else {
|
||||
var err = new Error("Type must be \"json\"");
|
||||
err.data = {type: type};
|
||||
throw err;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Create a transit writer handler.
|
||||
* @method transit.makeWriteHandler
|
||||
* @param {Object} obj
|
||||
* An object containing 3 functions, tag, rep and stringRep. "tag" should
|
||||
* return a string representing the tag to be written on the wire. "rep"
|
||||
* should return the representation on the wire. "stringRep" is should
|
||||
* return the string representation of the value. Optional
|
||||
* "getVerboseHandler" should return a handler for writing verbose output.
|
||||
* @return {Object} A transit write handler.
|
||||
* @example
|
||||
* var PointHandler = transit.makeWriteHandler({
|
||||
* tag: function(p) { return "point"; },
|
||||
* rep: function(p) { return [p.x, p.y]; },
|
||||
* stringRep: function(p) { return null; }
|
||||
* });
|
||||
*/
|
||||
transit.makeWriteHandler = function(obj) {
|
||||
/** @constructor */
|
||||
var Handler = function(){};
|
||||
Handler.prototype.tag = obj["tag"];
|
||||
Handler.prototype.rep = obj["rep"];
|
||||
Handler.prototype.stringRep = obj["stringRep"];
|
||||
Handler.prototype.getVerboseHandler = obj["getVerboseHandler"];
|
||||
return new Handler();
|
||||
};
|
||||
|
||||
transit.makeBuilder = function(obj) {
|
||||
/** @constructor */
|
||||
var Builder = function(){};
|
||||
Builder.prototype.init = obj["init"];
|
||||
Builder.prototype.add = obj["add"];
|
||||
Builder.prototype.finalize = obj["finalize"];
|
||||
Builder.prototype.fromArray = obj["fromArray"];
|
||||
return new Builder();
|
||||
};
|
||||
|
||||
/**
|
||||
* Create a transit date.
|
||||
* @method transit.date
|
||||
* @param {number|string} x
|
||||
* A number or string representing milliseconds since epoch.
|
||||
* @return {Date} A JavaScript Date.
|
||||
*/
|
||||
transit.date = types.date;
|
||||
|
||||
/**
|
||||
* Create an integer. If given a transit integer or a JavaScript
|
||||
* number will simply return that value. Given a string will
|
||||
* return a JavaScript number if the string represents an integer
|
||||
* value in the 53bit range and a transit integer otherwise.
|
||||
* @method transit.integer
|
||||
* @param {number|string} s
|
||||
* A value representing an integer.
|
||||
* @return {number|goog.math.Long} A JavaScript number or transit integer.
|
||||
*/
|
||||
transit.integer = types.intValue;
|
||||
|
||||
/**
|
||||
* Test if an object is a transit integer. Will return true if argument
|
||||
* is a 64 bit integer or a JavaScript number that has an interpretation as
|
||||
* an integer value, i.e. parseFloat(n) === parseInt(n)
|
||||
* @method transit.isInteger
|
||||
* @param {*} x
|
||||
* Any JavaScript value.
|
||||
* @return {boolean} true if the value is a transit integer, false otherwise.
|
||||
*/
|
||||
transit.isInteger = types.isInteger;
|
||||
|
||||
/**
|
||||
* Create transit UUID from a string
|
||||
* @method transit.uuid
|
||||
* @param {string} s
|
||||
* A string.
|
||||
* @return {com.cognitect.transit.types.UUID} A transit UUID.
|
||||
*/
|
||||
transit.uuid = types.uuid;
|
||||
|
||||
/**
|
||||
* Test if an object is a transit UUID.
|
||||
* @method transit.isUUID
|
||||
* @param {*} x
|
||||
* Any JavaScript value.
|
||||
* @return {boolean} true if the vlaue is a transit UUID instance, false otherwise.
|
||||
*/
|
||||
transit.isUUID = types.isUUID;
|
||||
|
||||
/**
|
||||
* Create a transit big integer.
|
||||
* @method transit.bigInt
|
||||
* @param {string} s
|
||||
* A string representing an arbitrary size integer value.
|
||||
* @return {com.cognitect.transit.types.TaggedValue} A transit big integer.
|
||||
*/
|
||||
transit.bigInt = types.bigInteger;
|
||||
|
||||
/**
|
||||
* Test if an object is a transit big integer.
|
||||
* @method transit.isBigInt
|
||||
* @param {*} x
|
||||
* Any JavaScript value.
|
||||
* @return {boolean} true if x is a transit big integer, false otherwise.
|
||||
*/
|
||||
transit.isBigInt = types.isBigInteger;
|
||||
|
||||
/**
|
||||
* Create a transit big decimal.
|
||||
* @method transit.bigDec
|
||||
* @param {string} s
|
||||
* A string representing an arbitrary precisions decimal value.
|
||||
* @return {com.cognitect.transit.types.TaggedValue} A transit big decimal.
|
||||
*/
|
||||
transit.bigDec = types.bigDecimalValue;
|
||||
|
||||
/**
|
||||
* Test if an object is a transit big decimal.
|
||||
* @method transit.isBigDec
|
||||
* @param {*} x
|
||||
* Any JavaScript value.
|
||||
* @return {boolean} true if x is a transit big decimal, false otherwise.
|
||||
*/
|
||||
transit.isBigDec = types.isBigDecimal;
|
||||
|
||||
/**
|
||||
* Create transit keyword.
|
||||
* @method transit.keyword
|
||||
* @param {string} name A string.
|
||||
* @return {com.cognitect.transit.types.Keyword} A transit keyword.
|
||||
* @example
|
||||
* transit.keyword("foo");
|
||||
*/
|
||||
transit.keyword = types.keyword;
|
||||
|
||||
/**
|
||||
* Test if an object is a transit keyword.
|
||||
* @method transit.isKeyword
|
||||
* @param {*} x
|
||||
* Any JavaScript value.
|
||||
* @return {boolean} true if x is a transit keyword, false otherwise.
|
||||
*/
|
||||
transit.isKeyword = types.isKeyword;
|
||||
|
||||
/**
|
||||
* Create a transit symbol.
|
||||
* @method transit.symbol
|
||||
* @param {string} name
|
||||
* A string.
|
||||
* @return {com.cognitect.transit.types.Symbol} A transit symbol instance.
|
||||
* @example
|
||||
* transit.symbol("foo");
|
||||
*/
|
||||
transit.symbol = types.symbol;
|
||||
|
||||
/**
|
||||
* Test if an object is a transit symbol
|
||||
* @method transit.isSymbol
|
||||
* @param {*} x
|
||||
* Any JavaScript value.
|
||||
* @return {boolean} true if x is a transit symbol, false otherwise.
|
||||
*/
|
||||
transit.isSymbol = types.isSymbol;
|
||||
|
||||
/**
|
||||
* Create transit binary blob.
|
||||
* @method transit.binary
|
||||
* @param {string} s
|
||||
* A base64 encoded string.
|
||||
* @param {*=} decoder
|
||||
* A Transit compliant decoder
|
||||
* @return {com.cognitect.transit.types.TaggedValue|Uint8Array} A transit binary blob instance.
|
||||
*/
|
||||
transit.binary = types.binary;
|
||||
|
||||
/**
|
||||
* Test if an object is a transit binary blob.
|
||||
* @method transit.isBinary
|
||||
* @param {*} x
|
||||
* Any JavaScript value.
|
||||
* @return {Boolean} true if x is a binary value, false otheriwse.
|
||||
*/
|
||||
transit.isBinary = types.isBinary;
|
||||
|
||||
/**
|
||||
* Create a transit URI.
|
||||
* @method transit.uri
|
||||
* @param {string} s
|
||||
* A string representing a valid URI.
|
||||
* @return {com.cognitect.transit.types.TaggedValue} A transit URI.
|
||||
*/
|
||||
transit.uri = types.uri;
|
||||
|
||||
/**
|
||||
* Test if an object is a transit URI.
|
||||
* @method transit.isURI
|
||||
* @param {*} x
|
||||
* Any JavaScript value.
|
||||
* @return {Boolean} true if x is a transit symbol, false otherwise.
|
||||
*/
|
||||
transit.isURI = types.isURI;
|
||||
|
||||
/**
|
||||
* Create a transit hash map. Transit maps satisfy the current version
|
||||
* of the ECMAScript 6 Map specification.
|
||||
* @method transit.map
|
||||
* @param {Array=} xs
|
||||
* A JavaScript array of alternating key value pairs.
|
||||
* @return {com.cognitect.transit.MapLike} A transit map.
|
||||
* @example
|
||||
* transit.map([new Date(), "foo", [1,2], 3]);
|
||||
*/
|
||||
transit.map = types.map;
|
||||
|
||||
/**
|
||||
* Test if an object is a transit map.
|
||||
* @method transit.isMap
|
||||
* @param {*} x
|
||||
* Any JavaScript value.
|
||||
* @return {boolean} true if x is a transit map, false otherwise.
|
||||
*/
|
||||
transit.isMap = types.isMap;
|
||||
|
||||
/**
|
||||
* Create a transit set. Transit sets satisfy the current version of the
|
||||
* of the ECMAScript 6 Set specification.
|
||||
* @method transit.set
|
||||
* @param {Array=} xs
|
||||
* A JavaScript array of values.
|
||||
* @return {com.cognitect.transit.SetLike} A transit set.
|
||||
* @example
|
||||
* transit.set(["foo", [1,2], 3, {bar: "baz"}]);
|
||||
*/
|
||||
transit.set = types.set;
|
||||
|
||||
/**
|
||||
* Test if an object is a transit set.
|
||||
* @method transit.isSet
|
||||
* @param {*} x
|
||||
* Any JavaScript value.
|
||||
* @return {boolean} true if x is a transit set, false otherwise.
|
||||
*/
|
||||
transit.isSet = types.isSet;
|
||||
|
||||
/**
|
||||
* Create a transit list.
|
||||
* @method transit.list
|
||||
* @param {Array} xs
|
||||
* A JavaScript array.
|
||||
* @return {com.cognitect.transit.types.TaggedValue} A transit list.
|
||||
*/
|
||||
transit.list = types.list;
|
||||
|
||||
/**
|
||||
* Test if an object is a transit list.
|
||||
* @method transit.isList
|
||||
* @param {*} x
|
||||
* Any JavaScript value.
|
||||
* @return {boolean} true if x is a transit list, false otherwise.
|
||||
*/
|
||||
transit.isList = types.isList;
|
||||
|
||||
/**
|
||||
* Create a transit quoted value.
|
||||
* @method transit.quoted
|
||||
* @param {*} x
|
||||
* Any JavaScript value.
|
||||
* @return {com.cognitect.transit.types.TaggedValue} A transit quoted value.
|
||||
*/
|
||||
transit.quoted = types.quoted;
|
||||
|
||||
/**
|
||||
* Test if an object is a transit quoted value.
|
||||
* @method transit.isQuoted
|
||||
* @param {*} x
|
||||
* Any JavaScript value.
|
||||
* @return {boolean} true if x is a transit value, false otherwise.
|
||||
*/
|
||||
transit.isQuoted = types.isQuoted;
|
||||
|
||||
/**
|
||||
* Create a transit tagged value.
|
||||
* @method transit.tagged
|
||||
* @param {string} tag A tag.
|
||||
* @param {*} value
|
||||
* A JavaScrpt array, object, or string.
|
||||
* @return {com.cognitect.transit.types.TaggedValue} A transit tagged value.
|
||||
* @example
|
||||
* transit.tagged("point", new Point(1,2));
|
||||
*/
|
||||
transit.tagged = types.taggedValue;
|
||||
|
||||
/**
|
||||
* Test if an object is a transit tagged value.
|
||||
* @method transit.isTaggedValue
|
||||
* @param {*} x
|
||||
* Any JavaScript value.
|
||||
* @return {boolean} true if x is a transit value, false otherwise.
|
||||
*/
|
||||
transit.isTaggedValue = types.isTaggedValue;
|
||||
|
||||
/**
|
||||
* Create a transit link.
|
||||
* @method transit.link
|
||||
* @param {com.cognitect.transit.MapLike} m
|
||||
* A transit map which must contain at a minimum the following keys:
|
||||
* href, rel. It may optionally include name, render, and prompt. href
|
||||
* must be a transit.uri, all other values are strings, and render must
|
||||
* be either "image" or "link".
|
||||
* @return {Object} A transit link.
|
||||
*/
|
||||
transit.link = types.link;
|
||||
|
||||
/**
|
||||
* Test if an object is a transit link.
|
||||
* @method transit.isLink
|
||||
* @param {*} x
|
||||
* Any JavaScript object.
|
||||
* @return {boolean} true if x is a transit link, false otherwise.
|
||||
*/
|
||||
transit.isLink = types.isLink;
|
||||
|
||||
/**
|
||||
* Compute the hashCode for any JavaScript object that has been
|
||||
* extend to transit's equality and hashing protocol. JavaScript
|
||||
* primitives and transit value are already extended to this protocol.
|
||||
* Custom types may be extended to the protocol via transit.extenToEQ.
|
||||
* @method transit.hash
|
||||
* @param {*} x
|
||||
* Any JavaScript object that has been extended to transit's equality
|
||||
* and hashing protocol.
|
||||
* @return {number} Returns JavaScript number - semantically a 32bit integer.
|
||||
*/
|
||||
transit.hash = eq.hashCode;
|
||||
|
||||
/**
|
||||
* Compute the hashCode for JavaScript map-like types - either a JavaScript
|
||||
* object or a JavaScript object that implements ES6 Map forEach.
|
||||
* @method transit.hashMapLike
|
||||
* @param {Object|com.cognitect.transit.MapLike} x
|
||||
* A plain JavaScript Object or Object that implements ES6 Map forEach.
|
||||
* @return {number} Returns JavaScript number - semantically a 32bit integer.
|
||||
*/
|
||||
transit.hashMapLike = eq.hashMapLike;
|
||||
|
||||
/**
|
||||
* Compute the hashCode for JavaScript array-like types - either a JavaScript
|
||||
* array or a JavaScript object that implements Array forEach.
|
||||
* @method transit.hashArrayLike
|
||||
* @param {Object} x
|
||||
* A JavaScript Array or Object that implements Array forEach.
|
||||
* @return {number} Returns JavaScript number - semantically a 32bit integer.
|
||||
*/
|
||||
transit.hashArrayLike = eq.hashArrayLike;
|
||||
|
||||
/**
|
||||
* Test whether two JavaScript objects represent equal values. The
|
||||
* objects to be tested should be extended to transit's equality
|
||||
* and hasing protocol. JavaScript natives and transit value have
|
||||
* already been extended to the protocol, including objects and
|
||||
* arrays. Also transit maps and JavaScript objects may be
|
||||
* compared for equality. Custom types may be extended via
|
||||
* transit.extendToEQ.
|
||||
* @param {*} x
|
||||
* A JavaScript object
|
||||
* @param {*} y
|
||||
* A JavaScript object
|
||||
* @return {Boolean} true if the x and y are equal, false otherwise.
|
||||
*/
|
||||
transit.equals = eq.equals;
|
||||
|
||||
/**
|
||||
* Extend an object to hashing and equality required by
|
||||
* transit maps and sets. Only required for custom
|
||||
* types, JavaScript primitive types and transit
|
||||
* types are handled.
|
||||
* @method transit.extendToEQ
|
||||
* @param {*} x
|
||||
* A JavaScript object, will be mutated.
|
||||
* @param {{hashCode: function(), equals: function(*,*):boolean}}
|
||||
* A JavaScript object supplying `hashCode` and `equals`
|
||||
* implementations
|
||||
* @return {*} x
|
||||
* @example
|
||||
* transit.extendToEq(Point.protototype, {
|
||||
* hashCode: function() {
|
||||
* var bits = (this.x | 0) ^ ((this.y | 0) * 31);
|
||||
* return bits ^ (bits >>> 32);
|
||||
* },
|
||||
* equals: function(other) {
|
||||
* return this.x == other.x && this.y == other.y;
|
||||
* }
|
||||
* });
|
||||
*/
|
||||
transit.extendToEQ = eq.extendToEQ;
|
||||
|
||||
/**
|
||||
* Convert a transit map instance into a JavaScript Object.
|
||||
* Throws if the map has keys which have no string representation.
|
||||
* @method transit.mapToObject
|
||||
* @param {com.cognitect.transit.MapLike} m
|
||||
* a transit map
|
||||
* @return {Object} a JavaScript Object
|
||||
*/
|
||||
transit.mapToObject = function(m) {
|
||||
var ret = {};
|
||||
m.forEach(function(v, k) {
|
||||
if(typeof k !== "string") {
|
||||
throw Error("Cannot convert map with non-string keys");
|
||||
} else {
|
||||
ret[k] = v;
|
||||
}
|
||||
});
|
||||
return ret;
|
||||
};
|
||||
|
||||
/**
|
||||
* Convert a POJO into a transit map.
|
||||
* @method transit.objectToMap
|
||||
* @param {Object} obj
|
||||
* a JavaScript Object
|
||||
* @return {com.cognitect.transit.MapLike} a transit map
|
||||
*/
|
||||
transit.objectToMap = function(obj) {
|
||||
var ret = transit.map();
|
||||
for(var p in obj) {
|
||||
if(obj.hasOwnProperty(p)) {
|
||||
ret.set(p, obj[p]);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
};
|
||||
|
||||
/**
|
||||
* Construct a Transit JSON decoder.
|
||||
* @method transit.decoder
|
||||
* @param {Object} opts
|
||||
* options to the decoder. Can include map of
|
||||
* handlers.
|
||||
* @return {com.cognitect.transit.impl.decoder.Decoder} a Transit JSON decoder
|
||||
* @example
|
||||
* var decoder = transit.decoder();
|
||||
* var x = decoder.decode(json, transit.readCache());
|
||||
*/
|
||||
transit.decoder = decoder.decoder;
|
||||
|
||||
/**
|
||||
* Construct a Transit read cache
|
||||
* @method transit.readCache
|
||||
* @return {com.cognitect.transit.caching.ReadCache} a Transit read cache
|
||||
*/
|
||||
transit.readCache = caching.readCache;
|
||||
|
||||
/**
|
||||
* Construct a Transit write cache
|
||||
* @method transit.writeCache
|
||||
* @return {com.cognitect.transit.caching.WriteCache} a Transit write cache
|
||||
*/
|
||||
transit.writeCache = caching.writeCache;
|
||||
|
||||
transit.UUIDfromString = types.UUIDfromString;
|
||||
transit.randomUUID = util.randomUUID;
|
||||
transit.stringableKeys = writer.stringableKeys;
|
||||
|
||||
if(TRANSIT_BROWSER_TARGET) {
|
||||
goog.exportSymbol("transit.reader", transit.reader);
|
||||
goog.exportSymbol("transit.writer", transit.writer);
|
||||
goog.exportSymbol("transit.makeBuilder", transit.makeBuilder);
|
||||
goog.exportSymbol("transit.makeWriteHandler", transit.makeWriteHandler);
|
||||
goog.exportSymbol("transit.date", types.date);
|
||||
goog.exportSymbol("transit.integer", types.intValue);
|
||||
goog.exportSymbol("transit.isInteger", types.isInteger);
|
||||
goog.exportSymbol("transit.uuid", types.uuid);
|
||||
goog.exportSymbol("transit.isUUID", types.isUUID);
|
||||
goog.exportSymbol("transit.bigInt", types.bigInteger);
|
||||
goog.exportSymbol("transit.isBigInt", types.isBigInteger);
|
||||
goog.exportSymbol("transit.bigDec", types.bigDecimalValue);
|
||||
goog.exportSymbol("transit.isBigDec", types.isBigDecimal);
|
||||
goog.exportSymbol("transit.keyword", types.keyword);
|
||||
goog.exportSymbol("transit.isKeyword", types.isKeyword);
|
||||
goog.exportSymbol("transit.symbol", types.symbol);
|
||||
goog.exportSymbol("transit.isSymbol", types.isSymbol);
|
||||
goog.exportSymbol("transit.binary", types.binary);
|
||||
goog.exportSymbol("transit.isBinary", types.isBinary);
|
||||
goog.exportSymbol("transit.uri", types.uri);
|
||||
goog.exportSymbol("transit.isURI", types.isURI);
|
||||
goog.exportSymbol("transit.map", types.map);
|
||||
goog.exportSymbol("transit.isMap", types.isMap);
|
||||
goog.exportSymbol("transit.set", types.set);
|
||||
goog.exportSymbol("transit.isSet", types.isSet);
|
||||
goog.exportSymbol("transit.list", types.list);
|
||||
goog.exportSymbol("transit.isList", types.isList);
|
||||
goog.exportSymbol("transit.quoted", types.quoted);
|
||||
goog.exportSymbol("transit.isQuoted", types.isQuoted);
|
||||
goog.exportSymbol("transit.tagged", types.taggedValue);
|
||||
goog.exportSymbol("transit.isTaggedValue", types.isTaggedValue);
|
||||
goog.exportSymbol("transit.link", types.link);
|
||||
goog.exportSymbol("transit.isLink", types.isLink);
|
||||
goog.exportSymbol("transit.hash", eq.hashCode);
|
||||
goog.exportSymbol("transit.hashMapLike", eq.hashMapLike);
|
||||
goog.exportSymbol("transit.hashArrayLike", eq.hashArrayLike);
|
||||
goog.exportSymbol("transit.equals", eq.equals);
|
||||
goog.exportSymbol("transit.extendToEQ", eq.extendToEQ);
|
||||
goog.exportSymbol("transit.mapToObject", transit.mapToObject);
|
||||
goog.exportSymbol("transit.objectToMap", transit.objectToMap);
|
||||
goog.exportSymbol("transit.decoder", decoder.decoder);
|
||||
goog.exportSymbol("transit.UUIDfromString", types.UUIDfromString);
|
||||
goog.exportSymbol("transit.randomUUID", util.randomUUID);
|
||||
goog.exportSymbol("transit.stringableKeys", writer.stringableKeys);
|
||||
goog.exportSymbol("transit.readCache", caching.readCache);
|
||||
goog.exportSymbol("transit.writeCache", caching.writeCache);
|
||||
}
|
||||
|
||||
if(TRANSIT_NODE_TARGET) {
|
||||
module.exports = {
|
||||
reader: transit.reader,
|
||||
writer: transit.writer,
|
||||
makeBuilder: transit.makeBuilder,
|
||||
makeWriteHandler: transit.makeWriteHandler,
|
||||
date: types.date,
|
||||
integer: types.intValue,
|
||||
isInteger: types.isInteger,
|
||||
uuid: types.uuid,
|
||||
isUUID: types.isUUID,
|
||||
bigInt: types.bigInteger,
|
||||
isBigInt: types.isBigInteger,
|
||||
bigDec: types.bigDecimalValue,
|
||||
isBigDec: types.isBigDecimal,
|
||||
keyword: types.keyword,
|
||||
isKeyword: types.isKeyword,
|
||||
symbol: types.symbol,
|
||||
isSymbol: types.isSymbol,
|
||||
binary: types.binary,
|
||||
isBinary: types.isBinary,
|
||||
uri: types.uri,
|
||||
isURI: types.isURI,
|
||||
map: types.map,
|
||||
isMap: types.isMap,
|
||||
set: types.set,
|
||||
isSet: types.isSet,
|
||||
list: types.list,
|
||||
isList: types.isList,
|
||||
quoted: types.quoted,
|
||||
isQuoted: types.isQuoted,
|
||||
tagged: types.taggedValue,
|
||||
isTaggedValue: types.isTaggedValue,
|
||||
link: types.link,
|
||||
isLink: types.isLink,
|
||||
hash: eq.hashCode,
|
||||
hashArrayLike: eq.hashArrayLike,
|
||||
hashMapLike: eq.hashMapLike,
|
||||
equals: eq.equals,
|
||||
extendToEQ: eq.extendToEQ,
|
||||
mapToObject: transit.mapToObject,
|
||||
objectToMap: transit.objectToMap,
|
||||
decoder: decoder.decoder,
|
||||
UUIDfromString: types.UUIDfromString,
|
||||
randomUUID: util.randomUUID,
|
||||
stringableKeys: writer.stringableKeys,
|
||||
readCache: caching.readCache,
|
||||
writeCache: caching.writeCache
|
||||
};
|
||||
}
|
||||
});
|
||||
|
|
@ -0,0 +1,177 @@
|
|||
// Copyright 2014 Cognitect. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS-IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
goog.provide("com.cognitect.transit.caching");
|
||||
goog.require("com.cognitect.transit.delimiters");
|
||||
|
||||
goog.scope(function() {
|
||||
|
||||
var caching = com.cognitect.transit.caching,
|
||||
d = com.cognitect.transit.delimiters;
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {number}
|
||||
*/
|
||||
caching.MIN_SIZE_CACHEABLE = 3;
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {number}
|
||||
*/
|
||||
caching.BASE_CHAR_IDX = 48;
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {number}
|
||||
*/
|
||||
caching.CACHE_CODE_DIGITS = 44;
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {number}
|
||||
*/
|
||||
caching.MAX_CACHE_ENTRIES = caching.CACHE_CODE_DIGITS*caching.CACHE_CODE_DIGITS;
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {number}
|
||||
*/
|
||||
caching.MAX_CACHE_SIZE = 4096;
|
||||
|
||||
caching.isCacheable = function(string, asMapKey) {
|
||||
if(string.length > caching.MIN_SIZE_CACHEABLE) {
|
||||
if(asMapKey) {
|
||||
return true;
|
||||
} else {
|
||||
var c0 = string.charAt(0),
|
||||
c1 = string.charAt(1);
|
||||
if(c0 === d.ESC) {
|
||||
return c1 === ":" || c1 === "$" || c1 === "#";
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
// =============================================================================
|
||||
// WriteCache
|
||||
|
||||
caching.idxToCode = function(idx) {
|
||||
var hi = Math.floor(idx / caching.CACHE_CODE_DIGITS),
|
||||
lo = idx % caching.CACHE_CODE_DIGITS,
|
||||
loc = String.fromCharCode(lo + caching.BASE_CHAR_IDX)
|
||||
if(hi === 0) {
|
||||
return d.SUB + loc;
|
||||
} else {
|
||||
return d.SUB + String.fromCharCode(hi + caching.BASE_CHAR_IDX) + loc;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
caching.WriteCache = function() {
|
||||
this.idx = 0;
|
||||
this.gen = 0;
|
||||
this.cacheSize = 0;
|
||||
this.cache = {};
|
||||
};
|
||||
|
||||
caching.WriteCache.prototype.write = function(string, asMapKey) {
|
||||
if(caching.isCacheable(string, asMapKey)) {
|
||||
if(this.cacheSize === caching.MAX_CACHE_SIZE) {
|
||||
this.clear();
|
||||
this.gen = 0;
|
||||
this.cache = {};
|
||||
} else if(this.idx === caching.MAX_CACHE_ENTRIES) {
|
||||
this.clear();
|
||||
}
|
||||
var entry = this.cache[string];
|
||||
if(entry == null) {
|
||||
this.cache[string] = [caching.idxToCode(this.idx), this.gen];
|
||||
this.idx++;
|
||||
return string;
|
||||
} else if(entry[1] != this.gen) {
|
||||
entry[1] = this.gen;
|
||||
entry[0] = caching.idxToCode(this.idx);
|
||||
this.idx++;
|
||||
return string;
|
||||
} else {
|
||||
return entry[0];
|
||||
}
|
||||
} else {
|
||||
return string;
|
||||
}
|
||||
};
|
||||
|
||||
caching.WriteCache.prototype.clear = function Transit$WriteCache() {
|
||||
this.idx = 0;
|
||||
this.gen++;
|
||||
};
|
||||
|
||||
caching.writeCache = function() {
|
||||
return new caching.WriteCache();
|
||||
};
|
||||
|
||||
// =============================================================================
|
||||
// ReadCache
|
||||
|
||||
caching.isCacheCode = function(string) {
|
||||
return (string.charAt(0) === d.SUB) && (string.charAt(1) !== " ");
|
||||
};
|
||||
|
||||
caching.codeToIdx = function(code) {
|
||||
if(code.length === 2) {
|
||||
return code.charCodeAt(1) - caching.BASE_CHAR_IDX;
|
||||
} else {
|
||||
var hi = (code.charCodeAt(1) - caching.BASE_CHAR_IDX) * caching.CACHE_CODE_DIGITS,
|
||||
lo = (code.charCodeAt(2) - caching.BASE_CHAR_IDX);
|
||||
return hi + lo;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
caching.ReadCache = function Transit$ReadCache() {
|
||||
this.idx = 0;
|
||||
this.cache = [];
|
||||
};
|
||||
|
||||
caching.ReadCache.prototype.write = function(obj, asMapKey) {
|
||||
if(this.idx == caching.MAX_CACHE_ENTRIES) {
|
||||
this.idx = 0;
|
||||
}
|
||||
this.cache[this.idx] = obj;
|
||||
this.idx++;
|
||||
return obj;
|
||||
};
|
||||
|
||||
caching.ReadCache.prototype.read = function(string, asMapKey) {
|
||||
return this.cache[caching.codeToIdx(string)];
|
||||
};
|
||||
|
||||
caching.ReadCache.prototype.clear = function() {
|
||||
this.idx = 0;
|
||||
};
|
||||
|
||||
caching.readCache = function() {
|
||||
return new caching.ReadCache();
|
||||
};
|
||||
|
||||
});
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
// Copyright 2014 Cognitect. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS-IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
goog.provide("com.cognitect.transit.delimiters");
|
||||
|
||||
goog.scope(function() {
|
||||
|
||||
var delimiters = com.cognitect.transit.delimiters;
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {string}
|
||||
*/
|
||||
delimiters.ESC = "~";
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {string}
|
||||
*/
|
||||
delimiters.TAG = "#";
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {string}
|
||||
*/
|
||||
delimiters.SUB = "^";
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {string}
|
||||
*/
|
||||
delimiters.RES = "`";
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {string}
|
||||
*/
|
||||
delimiters.ESC_TAG = "~#";
|
||||
|
||||
});
|
||||
|
|
@ -0,0 +1,204 @@
|
|||
// Copyright 2014 Cognitect. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS-IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
goog.provide("com.cognitect.transit.eq");
|
||||
goog.require("com.cognitect.transit.util");
|
||||
|
||||
goog.scope(function() {
|
||||
|
||||
var eq = com.cognitect.transit.eq,
|
||||
util = com.cognitect.transit.util;
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {string}
|
||||
*/
|
||||
eq.hashCodeProperty = "transit$hashCode$";
|
||||
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
eq.hashCodeCounter = 1;
|
||||
|
||||
eq.equals = function (x, y) {
|
||||
if(x == null) {
|
||||
return y == null;
|
||||
} else if(x === y) {
|
||||
return true;
|
||||
} else if(typeof x === "object") {
|
||||
if(util.isArray(x)) {
|
||||
if(util.isArray(y)) {
|
||||
if(x.length === y.length) {
|
||||
for(var i = 0; i < x.length; i++) {
|
||||
if(!eq.equals(x[i], y[i])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else if(x.com$cognitect$transit$equals) {
|
||||
return x.com$cognitect$transit$equals(y);
|
||||
} else if((y != null) && (typeof y === "object")) {
|
||||
if(y.com$cognitect$transit$equals) {
|
||||
return y.com$cognitect$transit$equals(x);
|
||||
} else {
|
||||
var xklen = 0,
|
||||
yklen = util.objectKeys(y).length;
|
||||
for(var p in x) {
|
||||
if(!x.hasOwnProperty(p)) continue;
|
||||
xklen++;
|
||||
if(!y.hasOwnProperty(p)) {
|
||||
return false;
|
||||
} else {
|
||||
if(!eq.equals(x[p], y[p])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return xklen === yklen;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
};
|
||||
|
||||
eq.hashCombine = function(seed, hash) {
|
||||
return seed ^ (hash + 0x9e3779b9 + (seed << 6) + (seed >> 2));
|
||||
};
|
||||
|
||||
eq.stringCodeCache = {};
|
||||
eq.stringCodeCacheSize = 0;
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {number}
|
||||
*/
|
||||
eq.STR_CACHE_MAX = 256;
|
||||
|
||||
eq.hashString = function(str) {
|
||||
// a la goog.string.HashCode
|
||||
// http://docs.closure-library.googlecode.com/git/local_closure_goog_string_string.js.source.html#line1206
|
||||
var cached = eq.stringCodeCache[str];
|
||||
if(cached != null) {
|
||||
return cached;
|
||||
}
|
||||
var code = 0;
|
||||
for (var i = 0; i < str.length; ++i) {
|
||||
code = 31 * code + str.charCodeAt(i);
|
||||
code %= 0x100000000;
|
||||
}
|
||||
eq.stringCodeCacheSize++;
|
||||
if(eq.stringCodeCacheSize >= eq.STR_CACHE_MAX) {
|
||||
eq.stringCodeCache = {};
|
||||
eq.stringCodeCacheSize = 1;
|
||||
}
|
||||
eq.stringCodeCache[str] = code;
|
||||
return code;
|
||||
};
|
||||
|
||||
eq.hashMapLike = function(m) {
|
||||
var code = 0;
|
||||
// ES6 Map-like case
|
||||
if(m.forEach != null) {
|
||||
m.forEach(function(val, key, m) {
|
||||
code = (code + (eq.hashCode(key) ^ eq.hashCode(val))) % 4503599627370496;
|
||||
});
|
||||
} else {
|
||||
// JS Object case
|
||||
var keys = util.objectKeys(m);
|
||||
for(var i = 0; i < keys.length; i++) {
|
||||
var key = keys[i];
|
||||
var val = m[key];
|
||||
code = (code + (eq.hashCode(key) ^ eq.hashCode(val))) % 4503599627370496;
|
||||
}
|
||||
}
|
||||
return code;
|
||||
};
|
||||
|
||||
eq.hashArrayLike = function(arr) {
|
||||
var code = 0;
|
||||
if(util.isArray(arr)) {
|
||||
for(var i = 0; i < arr.length; i++) {
|
||||
code = eq.hashCombine(code, eq.hashCode(arr[i]));
|
||||
}
|
||||
} else if(arr.forEach) {
|
||||
arr.forEach(function(x, i) {
|
||||
code = eq.hashCombine(code, eq.hashCode(x));
|
||||
});
|
||||
}
|
||||
return code;
|
||||
};
|
||||
|
||||
eq.hashCode = function(x) {
|
||||
if(x == null) {
|
||||
return 0;
|
||||
} else {
|
||||
switch(typeof x) {
|
||||
case 'number':
|
||||
return x;
|
||||
break;
|
||||
case 'boolean':
|
||||
return x === true ? 1 : 0;
|
||||
break;
|
||||
case 'string':
|
||||
return eq.hashString(x);
|
||||
break;
|
||||
case 'function':
|
||||
var code = x[eq.hashCodeProperty];
|
||||
if(code) {
|
||||
return code;
|
||||
} else {
|
||||
code = eq.hashCodeCounter;
|
||||
if(typeof Object.defineProperty != "undefined") {
|
||||
Object.defineProperty(x, eq.hashCodeProperty, {
|
||||
value: code,
|
||||
enumerable: false
|
||||
});
|
||||
} else {
|
||||
x[eq.hashCodeProperty] = code;
|
||||
}
|
||||
eq.hashCodeCounter++;
|
||||
return code;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if(x instanceof Date) {
|
||||
return x.valueOf();
|
||||
} else if(util.isArray(x)) {
|
||||
return eq.hashArrayLike(x);
|
||||
} if(x.com$cognitect$transit$hashCode) {
|
||||
return x.com$cognitect$transit$hashCode();
|
||||
} else {
|
||||
return eq.hashMapLike(x);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
eq.extendToEQ = function(obj, opts) {
|
||||
obj.com$cognitect$transit$hashCode = opts["hashCode"];
|
||||
obj.com$cognitect$transit$equals = opts["equals"];
|
||||
return obj;
|
||||
}
|
||||
|
||||
});
|
||||
|
|
@ -0,0 +1,444 @@
|
|||
// Copyright 2014 Cognitect. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS-IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
goog.provide("com.cognitect.transit.handlers");
|
||||
goog.require("com.cognitect.transit.util");
|
||||
goog.require("com.cognitect.transit.types");
|
||||
goog.require("goog.math.Long");
|
||||
|
||||
goog.scope(function () {
|
||||
|
||||
var handlers = com.cognitect.transit.handlers,
|
||||
util = com.cognitect.transit.util,
|
||||
types = com.cognitect.transit.types,
|
||||
Long = goog.math.Long;
|
||||
|
||||
handlers.ctorGuid = 0;
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {string}
|
||||
*/
|
||||
handlers.ctorGuidProperty = "transit$guid$" + util.randomUUID();
|
||||
|
||||
handlers.typeTag = function (ctor) {
|
||||
if (ctor == null) {
|
||||
return "null";
|
||||
} else if (ctor === String) {
|
||||
return "string";
|
||||
} else if (ctor === Boolean) {
|
||||
return "boolean";
|
||||
} else if (ctor === Number) {
|
||||
return "number";
|
||||
} else if (ctor === Array) {
|
||||
return "array";
|
||||
} else if (ctor === Object) {
|
||||
return "map";
|
||||
} else {
|
||||
var tag = ctor[handlers.ctorGuidProperty];
|
||||
if (tag == null) {
|
||||
if (typeof Object.defineProperty != "undefined") {
|
||||
tag = ++handlers.ctorGuid;
|
||||
Object.defineProperty(ctor, handlers.ctorGuidProperty, {
|
||||
value: tag,
|
||||
enumerable: false
|
||||
});
|
||||
} else {
|
||||
ctor[handlers.ctorGuidProperty] = tag = ++handlers.ctorGuid;
|
||||
}
|
||||
}
|
||||
return tag;
|
||||
}
|
||||
};
|
||||
|
||||
handlers.constructor = function (x) {
|
||||
if (x == null) {
|
||||
return null;
|
||||
} else {
|
||||
return x.constructor;
|
||||
}
|
||||
};
|
||||
|
||||
handlers.padZeros = function (n, m) {
|
||||
var s = n.toString();
|
||||
for (var i = s.length; i < m; i++) {
|
||||
s = "0" + s;
|
||||
}
|
||||
return s;
|
||||
};
|
||||
|
||||
handlers.stringableKeys = function (m) {
|
||||
var stringable = false,
|
||||
ks = util.objectKeys(m);
|
||||
|
||||
for (var i = 0; i < ks.length; i++) {
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
handlers.NilHandler = function Transit$NilHandler() {
|
||||
};
|
||||
handlers.NilHandler.prototype.tag = function (v) {
|
||||
return "_";
|
||||
};
|
||||
handlers.NilHandler.prototype.rep = function (v) {
|
||||
return null;
|
||||
};
|
||||
handlers.NilHandler.prototype.stringRep = function (v) {
|
||||
return "null";
|
||||
};
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
handlers.StringHandler = function Transit$StringHandler() {
|
||||
};
|
||||
handlers.StringHandler.prototype.tag = function (v) {
|
||||
return "s";
|
||||
};
|
||||
handlers.StringHandler.prototype.rep = function (v) {
|
||||
return v;
|
||||
};
|
||||
handlers.StringHandler.prototype.stringRep = function (v) {
|
||||
return v;
|
||||
};
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
handlers.NumberHandler = function Transit$NumberHandler() {
|
||||
};
|
||||
handlers.NumberHandler.prototype.tag = function (v) {
|
||||
return "i";
|
||||
};
|
||||
handlers.NumberHandler.prototype.rep = function (v) {
|
||||
return v;
|
||||
};
|
||||
handlers.NumberHandler.prototype.stringRep = function (v) {
|
||||
return v.toString();
|
||||
};
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
handlers.IntegerHandler = function Transit$IntegerHandler() {
|
||||
};
|
||||
handlers.IntegerHandler.prototype.tag = function (v) {
|
||||
return "i";
|
||||
};
|
||||
handlers.IntegerHandler.prototype.rep = function (v) {
|
||||
return v.toString();
|
||||
};
|
||||
handlers.IntegerHandler.prototype.stringRep = function (v) {
|
||||
return v.toString();
|
||||
};
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
handlers.BooleanHandler = function Transit$BooleanHandler() {
|
||||
};
|
||||
handlers.BooleanHandler.prototype.tag = function (v) {
|
||||
return "?";
|
||||
};
|
||||
handlers.BooleanHandler.prototype.rep = function (v) {
|
||||
return v;
|
||||
};
|
||||
handlers.BooleanHandler.prototype.stringRep = function (v) {
|
||||
return v.toString();
|
||||
};
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
handlers.ArrayHandler = function Transit$ArrayHandler() {
|
||||
};
|
||||
handlers.ArrayHandler.prototype.tag = function (v) {
|
||||
return "array";
|
||||
};
|
||||
handlers.ArrayHandler.prototype.rep = function (v) {
|
||||
return v;
|
||||
};
|
||||
handlers.ArrayHandler.prototype.stringRep = function (v) {
|
||||
return null;
|
||||
};
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
handlers.MapHandler = function Transit$MapHandler() {
|
||||
};
|
||||
handlers.MapHandler.prototype.tag = function (v) {
|
||||
return "map";
|
||||
};
|
||||
handlers.MapHandler.prototype.rep = function (v) {
|
||||
return v;
|
||||
};
|
||||
handlers.MapHandler.prototype.stringRep = function (v) {
|
||||
return null;
|
||||
};
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
handlers.VerboseDateHandler = function Transit$VerboseDateHandler() {
|
||||
};
|
||||
handlers.VerboseDateHandler.prototype.tag = function (v) {
|
||||
return "t";
|
||||
};
|
||||
handlers.VerboseDateHandler.prototype.rep = function (v) {
|
||||
return v.getUTCFullYear() + "-" + handlers.padZeros(v.getUTCMonth() + 1, 2) + "-" +
|
||||
handlers.padZeros(v.getUTCDate(), 2) + "T" + handlers.padZeros(v.getUTCHours(), 2) + ":" +
|
||||
handlers.padZeros(v.getUTCMinutes(), 2) + ":" + handlers.padZeros(v.getUTCSeconds(), 2) + "." +
|
||||
handlers.padZeros(v.getUTCMilliseconds(), 3) + "Z";
|
||||
};
|
||||
handlers.VerboseDateHandler.prototype.stringRep = function (v, h) {
|
||||
return h.rep(v);
|
||||
};
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
handlers.DateHandler = function Transit$DateHandler() {
|
||||
};
|
||||
handlers.DateHandler.prototype.tag = function (v) {
|
||||
return "m";
|
||||
};
|
||||
handlers.DateHandler.prototype.rep = function (v) {
|
||||
return v.valueOf();
|
||||
};
|
||||
handlers.DateHandler.prototype.stringRep = function (v) {
|
||||
return v.valueOf().toString();
|
||||
};
|
||||
handlers.DateHandler.prototype.getVerboseHandler = function (v) {
|
||||
return new handlers.VerboseDateHandler();
|
||||
};
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
handlers.UUIDHandler = function Transit$UUIDHandler() {
|
||||
};
|
||||
handlers.UUIDHandler.prototype.tag = function (v) {
|
||||
return "u";
|
||||
};
|
||||
handlers.UUIDHandler.prototype.rep = function (v) {
|
||||
return v.toString();
|
||||
};
|
||||
handlers.UUIDHandler.prototype.stringRep = function (v) {
|
||||
return v.toString();
|
||||
};
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
handlers.KeywordHandler = function Transit$KeywordHandler() {
|
||||
};
|
||||
handlers.KeywordHandler.prototype.tag = function (v) {
|
||||
return ":";
|
||||
};
|
||||
handlers.KeywordHandler.prototype.rep = function (v) {
|
||||
return v._name;
|
||||
}; // NOTE: should be fqn
|
||||
handlers.KeywordHandler.prototype.stringRep = function (v, h) {
|
||||
return h.rep(v);
|
||||
};
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
handlers.SymbolHandler = function Transit$SymbolHandler() {
|
||||
};
|
||||
handlers.SymbolHandler.prototype.tag = function (v) {
|
||||
return "$";
|
||||
};
|
||||
handlers.SymbolHandler.prototype.rep = function (v) {
|
||||
return v._name;
|
||||
}; // NOTE: should be str
|
||||
handlers.SymbolHandler.prototype.stringRep = function (v, h) {
|
||||
return h.rep(v);
|
||||
};
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
handlers.TaggedHandler = function Transit$TaggedHandler() {
|
||||
};
|
||||
handlers.TaggedHandler.prototype.tag = function (v) {
|
||||
return v.tag;
|
||||
};
|
||||
handlers.TaggedHandler.prototype.rep = function (v) {
|
||||
return v.rep;
|
||||
};
|
||||
handlers.TaggedHandler.prototype.stringRep = function (v, h) {
|
||||
return null;
|
||||
};
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
handlers.TransitSetHandler = function Transit$TransitSetHandler() {
|
||||
};
|
||||
handlers.TransitSetHandler.prototype.tag = function (v) {
|
||||
return "set";
|
||||
};
|
||||
handlers.TransitSetHandler.prototype.rep = function (v) {
|
||||
var arr = [];
|
||||
v.forEach(function (key, set) {
|
||||
arr.push(key);
|
||||
});
|
||||
return types.taggedValue("array", arr);
|
||||
};
|
||||
handlers.TransitSetHandler.prototype.stringRep = function (v, h) {
|
||||
return null;
|
||||
};
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
handlers.TransitArrayMapHandler = function Transit$ArrayMapHandler() {
|
||||
};
|
||||
handlers.TransitArrayMapHandler.prototype.tag = function (v) {
|
||||
return "map";
|
||||
};
|
||||
handlers.TransitArrayMapHandler.prototype.rep = function (v) {
|
||||
return v;
|
||||
};
|
||||
handlers.TransitArrayMapHandler.prototype.stringRep = function (v, h) {
|
||||
return null;
|
||||
};
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
handlers.TransitMapHandler = function Transit$MapHandler() {
|
||||
};
|
||||
handlers.TransitMapHandler.prototype.tag = function (v) {
|
||||
return "map";
|
||||
};
|
||||
handlers.TransitMapHandler.prototype.rep = function (v) {
|
||||
return v;
|
||||
};
|
||||
handlers.TransitMapHandler.prototype.stringRep = function (v, h) {
|
||||
return null;
|
||||
};
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
handlers.BufferHandler = function Transit$BufferHandler() {
|
||||
};
|
||||
handlers.BufferHandler.prototype.tag = function (v) {
|
||||
return "b";
|
||||
};
|
||||
handlers.BufferHandler.prototype.rep = function (v) {
|
||||
return v.toString("base64");
|
||||
};
|
||||
handlers.BufferHandler.prototype.stringRep = function (v, h) {
|
||||
return null;
|
||||
};
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
handlers.Uint8ArrayHandler = function Transit$Uint8ArrayHandler() {
|
||||
};
|
||||
handlers.Uint8ArrayHandler.prototype.tag = function (v) {
|
||||
return "b";
|
||||
};
|
||||
handlers.Uint8ArrayHandler.prototype.rep = function (v) {
|
||||
return util.Uint8ToBase64(v);
|
||||
};
|
||||
handlers.Uint8ArrayHandler.prototype.stringRep = function (v, h) {
|
||||
return null;
|
||||
};
|
||||
|
||||
handlers.defaultHandlers = function (hs) {
|
||||
hs.set(null, new handlers.NilHandler());
|
||||
hs.set(String, new handlers.StringHandler());
|
||||
hs.set(Number, new handlers.NumberHandler());
|
||||
hs.set(Long, new handlers.IntegerHandler());
|
||||
hs.set(Boolean, new handlers.BooleanHandler());
|
||||
hs.set(Array, new handlers.ArrayHandler());
|
||||
hs.set(Object, new handlers.MapHandler());
|
||||
hs.set(Date, new handlers.DateHandler());
|
||||
hs.set(types.UUID, new handlers.UUIDHandler());
|
||||
hs.set(types.Keyword, new handlers.KeywordHandler());
|
||||
hs.set(types.Symbol, new handlers.SymbolHandler());
|
||||
hs.set(types.TaggedValue, new handlers.TaggedHandler());
|
||||
hs.set(types.TransitSet, new handlers.TransitSetHandler());
|
||||
hs.set(types.TransitArrayMap, new handlers.TransitArrayMapHandler());
|
||||
hs.set(types.TransitMap, new handlers.TransitMapHandler());
|
||||
|
||||
if (typeof Buffer != "undefined") {
|
||||
hs.set(Buffer, new handlers.BufferHandler());
|
||||
}
|
||||
|
||||
if (typeof Uint8Array != "undefined") {
|
||||
hs.set(Uint8Array, new handlers.Uint8ArrayHandler());
|
||||
}
|
||||
|
||||
return hs;
|
||||
};
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
handlers.Handlers = function Transit$Handlers() {
|
||||
this.handlers = {};
|
||||
handlers.defaultHandlers(this);
|
||||
};
|
||||
|
||||
handlers.Handlers.prototype.get = function (ctor) {
|
||||
var h = null;
|
||||
if (typeof ctor === "string") {
|
||||
h = this.handlers[ctor];
|
||||
} else {
|
||||
h = this.handlers[handlers.typeTag(ctor)];
|
||||
}
|
||||
if (h != null) {
|
||||
return h;
|
||||
} else {
|
||||
return this.handlers["default"];
|
||||
}
|
||||
};
|
||||
handlers.Handlers.prototype["get"] = handlers.Handlers.prototype.get;
|
||||
|
||||
handlers.validTag = function (tag) {
|
||||
switch (tag) {
|
||||
case "null":
|
||||
case "string":
|
||||
case "boolean":
|
||||
case "number":
|
||||
case "array":
|
||||
case "map":
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
handlers.Handlers.prototype.set = function (ctor, handler) {
|
||||
if (typeof ctor === "string" && handlers.validTag(ctor)) {
|
||||
this.handlers[ctor] = handler;
|
||||
} else {
|
||||
this.handlers[handlers.typeTag(ctor)] = handler;
|
||||
}
|
||||
};
|
||||
|
||||
});
|
||||
|
|
@ -0,0 +1,364 @@
|
|||
// Copyright 2014 Cognitect. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS-IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
goog.provide("com.cognitect.transit.impl.decoder");
|
||||
goog.require("com.cognitect.transit.util");
|
||||
goog.require("com.cognitect.transit.delimiters");
|
||||
goog.require("com.cognitect.transit.caching");
|
||||
goog.require("com.cognitect.transit.types");
|
||||
|
||||
goog.scope(function () {
|
||||
|
||||
var decoder = com.cognitect.transit.impl.decoder,
|
||||
util = com.cognitect.transit.util,
|
||||
d = com.cognitect.transit.delimiters,
|
||||
caching = com.cognitect.transit.caching,
|
||||
types = com.cognitect.transit.types;
|
||||
|
||||
// =========================================================================
|
||||
// Decoder
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
decoder.Tag = function Transit$Tag(s) {
|
||||
this.str = s;
|
||||
};
|
||||
|
||||
decoder.tag = function (s) {
|
||||
return new decoder.Tag(s);
|
||||
};
|
||||
|
||||
decoder.isTag = function (x) {
|
||||
return x && (x instanceof decoder.Tag);
|
||||
};
|
||||
|
||||
decoder.isGroundHandler = function (handler) {
|
||||
switch (handler) {
|
||||
case "_":
|
||||
case "s":
|
||||
case "?":
|
||||
case "i":
|
||||
case "d":
|
||||
case "b":
|
||||
case "'":
|
||||
case "array":
|
||||
case "map":
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
/**
|
||||
* A transit decoder
|
||||
* @constructor
|
||||
*/
|
||||
decoder.Decoder = function Transit$Decoder(options) {
|
||||
this.options = options || {};
|
||||
this.handlers = {};
|
||||
for (var h in this.defaults.handlers) {
|
||||
this.handlers[h] = this.defaults.handlers[h];
|
||||
}
|
||||
for (var h in this.options["handlers"]) {
|
||||
if (decoder.isGroundHandler(h)) {
|
||||
throw new Error("Cannot override handler for ground type \"" + h + "\"");
|
||||
}
|
||||
this.handlers[h] = this.options["handlers"][h];
|
||||
}
|
||||
this.preferStrings = this.options["preferStrings"] != null ? this.options["preferStrings"] : this.defaults.preferStrings;
|
||||
this.preferBuffers = this.options["preferBuffers"] != null ? this.options["preferBuffers"] : this.defaults.preferBuffers;
|
||||
this.defaultHandler = this.options["defaultHandler"] || this.defaults.defaultHandler;
|
||||
/* NOT PUBLIC */
|
||||
this.mapBuilder = this.options["mapBuilder"];
|
||||
this.arrayBuilder = this.options["arrayBuilder"];
|
||||
};
|
||||
|
||||
|
||||
decoder.Decoder.prototype.defaults = {
|
||||
handlers: {
|
||||
"_": function (v, d) {
|
||||
return types.nullValue();
|
||||
},
|
||||
"?": function (v, d) {
|
||||
return types.boolValue(v);
|
||||
},
|
||||
"b": function (v, d) {
|
||||
return types.binary(v, d);
|
||||
},
|
||||
"i": function (v, d) {
|
||||
return types.intValue(v);
|
||||
},
|
||||
"n": function (v, d) {
|
||||
return types.bigInteger(v);
|
||||
},
|
||||
"d": function (v, d) {
|
||||
return types.floatValue(v);
|
||||
},
|
||||
"f": function (v, d) {
|
||||
return types.bigDecimalValue(v);
|
||||
},
|
||||
"c": function (v, d) {
|
||||
return types.charValue(v);
|
||||
},
|
||||
":": function (v, d) {
|
||||
return types.keyword(v);
|
||||
},
|
||||
"$": function (v, d) {
|
||||
return types.symbol(v);
|
||||
},
|
||||
"r": function (v, d) {
|
||||
return types.uri(v);
|
||||
},
|
||||
"z": function (v, d) {
|
||||
return types.specialDouble(v);
|
||||
},
|
||||
|
||||
// tagged
|
||||
"'": function (v, d) {
|
||||
return v;
|
||||
},
|
||||
"m": function (v, d) {
|
||||
return types.date(v);
|
||||
},
|
||||
"t": function (v, d) {
|
||||
return types.verboseDate(v);
|
||||
},
|
||||
"u": function (v, d) {
|
||||
return types.uuid(v);
|
||||
},
|
||||
"set": function (v, d) {
|
||||
return types.set(v);
|
||||
},
|
||||
"list": function (v, d) {
|
||||
return types.list(v);
|
||||
},
|
||||
"link": function (v, d) {
|
||||
return types.link(v);
|
||||
},
|
||||
"cmap": function (v, d) {
|
||||
return types.map(v, false);
|
||||
}
|
||||
},
|
||||
defaultHandler: function (c, val) {
|
||||
return types.taggedValue(c, val);
|
||||
},
|
||||
preferStrings: true,
|
||||
preferBuffers: true
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {*} node
|
||||
* @param {*} cache
|
||||
* @param {boolean=} asMapKey
|
||||
* @param {boolean=} tagValue
|
||||
* @returns {*}
|
||||
*/
|
||||
decoder.Decoder.prototype.decode = function (node, cache, asMapKey, tagValue) {
|
||||
if (node == null) return null;
|
||||
|
||||
var t = typeof node;
|
||||
|
||||
switch (t) {
|
||||
case "string":
|
||||
return this.decodeString(node, cache, asMapKey, tagValue);
|
||||
break;
|
||||
case "object":
|
||||
if (util.isArray(node)) {
|
||||
if (node[0] === "^ ") {
|
||||
return this.decodeArrayHash(node, cache, asMapKey, tagValue);
|
||||
} else {
|
||||
return this.decodeArray(node, cache, asMapKey, tagValue);
|
||||
}
|
||||
} else {
|
||||
return this.decodeHash(node, cache, asMapKey, tagValue);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return node;
|
||||
};
|
||||
decoder.Decoder.prototype["decode"] = decoder.Decoder.prototype.decode;
|
||||
|
||||
decoder.Decoder.prototype.decodeString = function (string, cache, asMapKey, tagValue) {
|
||||
if (caching.isCacheable(string, asMapKey)) {
|
||||
var val = this.parseString(string, cache, false);
|
||||
if (cache) {
|
||||
cache.write(val, asMapKey);
|
||||
}
|
||||
return val;
|
||||
} else if (caching.isCacheCode(string)) {
|
||||
return cache.read(string, asMapKey);
|
||||
} else {
|
||||
return this.parseString(string, cache, asMapKey);
|
||||
}
|
||||
};
|
||||
|
||||
decoder.Decoder.prototype.decodeHash = function (hash, cache, asMapKey, tagValue) {
|
||||
var ks = util.objectKeys(hash),
|
||||
key = ks[0],
|
||||
tag = ks.length == 1 ? this.decode(key, cache, false, false) : null;
|
||||
|
||||
if (decoder.isTag(tag)) {
|
||||
var val = hash[key],
|
||||
handler = this.handlers[tag.str];
|
||||
if (handler != null) {
|
||||
return handler(this.decode(val, cache, false, true), this);
|
||||
} else {
|
||||
return types.taggedValue(tag.str, this.decode(val, cache, false, false));
|
||||
}
|
||||
} else if (this.mapBuilder) {
|
||||
if ((ks.length < (types.SMALL_ARRAY_MAP_THRESHOLD * 2)) && this.mapBuilder.fromArray) {
|
||||
var nodep = [];
|
||||
for (var i = 0; i < ks.length; i++) {
|
||||
var strKey = ks[i];
|
||||
nodep.push(this.decode(strKey, cache, true, false));
|
||||
nodep.push(this.decode(hash[strKey], cache, false, false));
|
||||
}
|
||||
return this.mapBuilder.fromArray(nodep, hash);
|
||||
} else {
|
||||
var ret = this.mapBuilder.init(hash);
|
||||
for (var i = 0; i < ks.length; i++) {
|
||||
var strKey = ks[i];
|
||||
ret = this.mapBuilder.add(ret,
|
||||
this.decode(strKey, cache, true, false),
|
||||
this.decode(hash[strKey], cache, false, false),
|
||||
hash);
|
||||
}
|
||||
return this.mapBuilder.finalize(ret, hash);
|
||||
}
|
||||
} else {
|
||||
var nodep = [];
|
||||
|
||||
for (var i = 0; i < ks.length; i++) {
|
||||
var strKey = ks[i];
|
||||
nodep.push(this.decode(strKey, cache, true, false));
|
||||
nodep.push(this.decode(hash[strKey], cache, false, false));
|
||||
}
|
||||
|
||||
return types.map(nodep, false);
|
||||
}
|
||||
};
|
||||
|
||||
decoder.Decoder.prototype.decodeArrayHash = function (node, cache, asMapKey, tagValue) {
|
||||
if (this.mapBuilder) {
|
||||
if ((node.length < ((types.SMALL_ARRAY_MAP_THRESHOLD * 2) + 1)) && this.mapBuilder.fromArray) {
|
||||
var nodep = [];
|
||||
for (var i = 1; i < node.length; i += 2) {
|
||||
nodep.push(this.decode(node[i], cache, true, false));
|
||||
nodep.push(this.decode(node[i + 1], cache, false, false));
|
||||
}
|
||||
return this.mapBuilder.fromArray(nodep, node);
|
||||
} else {
|
||||
var ret = this.mapBuilder.init(node);
|
||||
for (var i = 1; i < node.length; i += 2) {
|
||||
ret = this.mapBuilder.add(ret,
|
||||
this.decode(node[i], cache, true, false),
|
||||
this.decode(node[i + 1], cache, false, false),
|
||||
node)
|
||||
}
|
||||
return this.mapBuilder.finalize(ret, node);
|
||||
}
|
||||
} else {
|
||||
var nodep = [];
|
||||
|
||||
// collect keys
|
||||
for (var i = 1; i < node.length; i += 2) {
|
||||
nodep.push(this.decode(node[i], cache, true, false));
|
||||
nodep.push(this.decode(node[i + 1], cache, false, false));
|
||||
}
|
||||
|
||||
return types.map(nodep, false);
|
||||
}
|
||||
};
|
||||
|
||||
decoder.Decoder.prototype.decodeArray = function (node, cache, asMapKey, tagValue) {
|
||||
if (tagValue) {
|
||||
var ret = [];
|
||||
for (var i = 0; i < node.length; i++) {
|
||||
ret.push(this.decode(node[i], cache, asMapKey, false));
|
||||
}
|
||||
return ret;
|
||||
} else {
|
||||
var cacheIdx = cache && cache.idx;
|
||||
// tagged value as 2-array case
|
||||
if ((node.length === 2) &&
|
||||
(typeof node[0] === "string")) {
|
||||
var tag = this.decode(node[0], cache, false, false);
|
||||
if (decoder.isTag(tag)) {
|
||||
var val = node[1],
|
||||
handler = this.handlers[tag.str];
|
||||
if (handler != null) {
|
||||
var ret = handler(this.decode(val, cache, asMapKey, true), this);
|
||||
return ret;
|
||||
} else {
|
||||
return types.taggedValue(tag.str, this.decode(val, cache, asMapKey, false))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// rewind cache
|
||||
if (cache && (cacheIdx != cache.idx)) {
|
||||
cache.idx = cacheIdx;
|
||||
}
|
||||
|
||||
if (this.arrayBuilder) {
|
||||
// NOTE: hard coded for ClojureScript for now - David
|
||||
if (node.length <= 32 && this.arrayBuilder.fromArray) {
|
||||
var arr = [];
|
||||
for (var i = 0; i < node.length; i++) {
|
||||
arr.push(this.decode(node[i], cache, asMapKey, false));
|
||||
}
|
||||
return this.arrayBuilder.fromArray(arr, node);
|
||||
} else {
|
||||
var ret = this.arrayBuilder.init(node);
|
||||
for (var i = 0; i < node.length; i++) {
|
||||
ret = this.arrayBuilder.add(ret, this.decode(node[i], cache, asMapKey, false), node);
|
||||
}
|
||||
return this.arrayBuilder.finalize(ret, node);
|
||||
}
|
||||
} else {
|
||||
var ret = [];
|
||||
for (var i = 0; i < node.length; i++) {
|
||||
ret.push(this.decode(node[i], cache, asMapKey, false));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
decoder.Decoder.prototype.parseString = function (string, cache, asMapKey) {
|
||||
if (string.charAt(0) === d.ESC) {
|
||||
var c = string.charAt(1);
|
||||
if (c === d.ESC || c === d.SUB || c === d.RES) {
|
||||
return string.substring(1);
|
||||
} else if (c === d.TAG) {
|
||||
return decoder.tag(string.substring(2));
|
||||
} else {
|
||||
var handler = this.handlers[c];
|
||||
if (handler == null) {
|
||||
return this.defaultHandler(c, string.substring(2));
|
||||
} else {
|
||||
return handler(string.substring(2), this);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return string;
|
||||
}
|
||||
};
|
||||
|
||||
decoder.decoder = function (options) {
|
||||
return new decoder.Decoder(options);
|
||||
};
|
||||
|
||||
});
|
||||
|
|
@ -0,0 +1,65 @@
|
|||
// Copyright 2014 Cognitect. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS-IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
goog.provide("com.cognitect.transit.impl.reader");
|
||||
goog.require("com.cognitect.transit.impl.decoder");
|
||||
goog.require("com.cognitect.transit.caching");
|
||||
|
||||
goog.scope(function () {
|
||||
|
||||
var reader = com.cognitect.transit.impl.reader,
|
||||
decoder = com.cognitect.transit.impl.decoder,
|
||||
caching = com.cognitect.transit.caching;
|
||||
|
||||
/**
|
||||
* A JSON unmarshaller
|
||||
* @constructor
|
||||
*/
|
||||
reader.JSONUnmarshaller = function Transit$JSONUnmarshaller(opts) {
|
||||
this.decoder = new decoder.Decoder(opts);
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} str a JSON string
|
||||
* @param {caching.ReadCache} cache a read cache
|
||||
* @returns {*}
|
||||
*/
|
||||
reader.JSONUnmarshaller.prototype.unmarshal = function (str, cache) {
|
||||
return this.decoder.decode(JSON.parse(str), cache);
|
||||
};
|
||||
|
||||
/**
|
||||
* A transit reader
|
||||
* @constructor
|
||||
* @param {reader.JSONUnmarshaller} unmarshaller
|
||||
* @param {Object=} options
|
||||
*/
|
||||
reader.Reader = function Transit$Reader(unmarshaller, options) {
|
||||
this.unmarshaller = unmarshaller;
|
||||
this.options = options || {};
|
||||
this.cache = this.options["cache"] ? this.options["cache"] : new caching.ReadCache();
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} str a string to be read
|
||||
* @returns {*}
|
||||
*/
|
||||
reader.Reader.prototype.read = function (str) {
|
||||
var ret = this.unmarshaller.unmarshal(str, this.cache)
|
||||
this.cache.clear();
|
||||
return ret;
|
||||
};
|
||||
reader.Reader.prototype["read"] = reader.Reader.prototype.read;
|
||||
|
||||
});
|
||||
|
|
@ -0,0 +1,515 @@
|
|||
// Copyright 2014 Cognitect. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS-IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
goog.provide("com.cognitect.transit.impl.writer");
|
||||
goog.require("com.cognitect.transit.util");
|
||||
goog.require("com.cognitect.transit.caching");
|
||||
goog.require("com.cognitect.transit.handlers");
|
||||
goog.require("com.cognitect.transit.types");
|
||||
goog.require("com.cognitect.transit.delimiters");
|
||||
goog.require("goog.math.Long");
|
||||
|
||||
goog.scope(function () {
|
||||
|
||||
var writer = com.cognitect.transit.impl.writer,
|
||||
util = com.cognitect.transit.util,
|
||||
caching = com.cognitect.transit.caching,
|
||||
handlers = com.cognitect.transit.handlers,
|
||||
types = com.cognitect.transit.types,
|
||||
d = com.cognitect.transit.delimiters,
|
||||
Long = goog.math.Long;
|
||||
|
||||
writer.escape = function (string) {
|
||||
if (string.length > 0) {
|
||||
var c = string.charAt(0);
|
||||
if (c === d.ESC || c === d.SUB || c === d.RES) {
|
||||
return d.ESC + string;
|
||||
} else {
|
||||
return string;
|
||||
}
|
||||
} else {
|
||||
return string;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
writer.JSONMarshaller = function Transit$JSONMarshaller(opts) {
|
||||
this.opts = opts || {};
|
||||
this.preferStrings = this.opts["preferStrings"] != null ? this.opts["preferStrings"] : true;
|
||||
|
||||
this.objectBuilder = this.opts["objectBuilder"] || null;
|
||||
|
||||
this.handlers = new handlers.Handlers();
|
||||
|
||||
var optsHandlers = this.opts["handlers"];
|
||||
if (optsHandlers) {
|
||||
if (util.isArray(optsHandlers) || !optsHandlers.forEach) {
|
||||
throw new Error("transit writer \"handlers\" option must be a map");
|
||||
}
|
||||
var self = this;
|
||||
optsHandlers.forEach(function (v, k) {
|
||||
if (k !== undefined) {
|
||||
self.handlers.set(k, v);
|
||||
} else {
|
||||
throw new Error("Cannot create handler for JavaScript undefined");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Multiple JS context helper
|
||||
this.handlerForForeign = this.opts["handlerForForeign"];
|
||||
|
||||
this.unpack = this.opts["unpack"] || function (x) {
|
||||
if (types.isArrayMap(x) && x.backingMap === null) {
|
||||
return x._entries;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
this.verbose = (this.opts && this.opts["verbose"]) || false;
|
||||
};
|
||||
|
||||
writer.JSONMarshaller.prototype.handler = function (obj) {
|
||||
var h = this.handlers.get(handlers.constructor(obj));
|
||||
|
||||
if (h != null) {
|
||||
return h;
|
||||
} else {
|
||||
var tag = obj && obj["transitTag"];
|
||||
if (tag) {
|
||||
return this.handlers.get(tag)
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
writer.JSONMarshaller.prototype.registerHandler = function (ctor, handler) {
|
||||
this.handlers.set(ctor, handler);
|
||||
};
|
||||
|
||||
writer.JSONMarshaller.prototype.emitNil = function (asMapKey, cache) {
|
||||
if (asMapKey) {
|
||||
return this.emitString(d.ESC, "_", "", asMapKey, cache);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
writer.JSONMarshaller.prototype.emitString = function (prefix, tag, s, asMapKey, cache) {
|
||||
var string = prefix + tag + s;
|
||||
if (cache) {
|
||||
return cache.write(string, asMapKey);
|
||||
} else {
|
||||
return string;
|
||||
}
|
||||
};
|
||||
|
||||
writer.JSONMarshaller.prototype.emitBoolean = function (b, asMapKey, cache) {
|
||||
if (asMapKey) {
|
||||
var s = b.toString();
|
||||
return this.emitString(d.ESC, "?", s[0], asMapKey, cache);
|
||||
} else {
|
||||
return b;
|
||||
}
|
||||
};
|
||||
|
||||
writer.JSONMarshaller.prototype.emitInteger = function (i, asMapKey, cache) {
|
||||
if (i === Infinity) {
|
||||
return this.emitString(d.ESC, "z", "INF", asMapKey, cache);
|
||||
} else if (i === -Infinity) {
|
||||
return this.emitString(d.ESC, "z", "-INF", asMapKey, cache);
|
||||
} else if (isNaN(i)) {
|
||||
return this.emitString(d.ESC, "z", "NaN", asMapKey, cache);
|
||||
} else if (asMapKey || (typeof i === "string") || (i instanceof Long)) {
|
||||
return this.emitString(d.ESC, "i", i.toString(), asMapKey, cache);
|
||||
} else {
|
||||
return i;
|
||||
}
|
||||
};
|
||||
|
||||
writer.JSONMarshaller.prototype.emitDouble = function (d, asMapKey, cache) {
|
||||
if (asMapKey) {
|
||||
return this.emitString(d.ESC, "d", d, asMapKey, cache);
|
||||
} else {
|
||||
return d;
|
||||
}
|
||||
};
|
||||
|
||||
writer.JSONMarshaller.prototype.emitBinary = function (b, asMapKey, cache) {
|
||||
return this.emitString(d.ESC, "b", b, asMapKey, cache);
|
||||
};
|
||||
|
||||
writer.JSONMarshaller.prototype.emitQuoted = function (em, obj, cache) {
|
||||
if (em.verbose) {
|
||||
var ret = {},
|
||||
k = this.emitString(d.ESC_TAG, "'", "", true, cache);
|
||||
ret[k] = writer.marshal(this, obj, false, cache);
|
||||
return ret;
|
||||
} else {
|
||||
return [this.emitString(d.ESC_TAG, "'", "", true, cache), writer.marshal(this, obj, false, cache)];
|
||||
}
|
||||
};
|
||||
|
||||
writer.emitObjects = function (em, iterable, cache) {
|
||||
var ret = [];
|
||||
if (util.isArray(iterable)) {
|
||||
for (var i = 0; i < iterable.length; i++) {
|
||||
ret.push(writer.marshal(em, iterable[i], false, cache));
|
||||
}
|
||||
} else {
|
||||
iterable.forEach(function (v, i) {
|
||||
ret.push(writer.marshal(em, v, false, cache));
|
||||
});
|
||||
}
|
||||
return ret;
|
||||
};
|
||||
|
||||
writer.emitArray = function (em, iterable, skip, cache) {
|
||||
return writer.emitObjects(em, iterable, cache);
|
||||
};
|
||||
|
||||
writer.isStringableKey = function (em, k) {
|
||||
if (typeof k !== "string") {
|
||||
var h = em.handler(k);
|
||||
return h && h.tag(k).length === 1;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns true if map-like obj parameter has only stringable keys -
|
||||
* strings, symbols or keywords. If false, obj is a cmap value.
|
||||
* @param em
|
||||
* @param obj
|
||||
* @returns {boolean}
|
||||
*/
|
||||
writer.stringableKeys = function (em, obj) {
|
||||
var arr = em.unpack(obj),
|
||||
stringableKeys = true;
|
||||
|
||||
if (arr) {
|
||||
for (var i = 0; i < arr.length; i += 2) {
|
||||
stringableKeys = writer.isStringableKey(em, arr[i]);
|
||||
if (!stringableKeys) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return stringableKeys;
|
||||
} else if (obj.keys) {
|
||||
var iter = obj.keys(),
|
||||
step = null;
|
||||
|
||||
if (iter.next) {
|
||||
step = iter.next();
|
||||
while (!step.done) {
|
||||
stringableKeys = writer.isStringableKey(em, step.value);
|
||||
if (!stringableKeys) {
|
||||
break;
|
||||
}
|
||||
step = iter.next();
|
||||
}
|
||||
return stringableKeys;
|
||||
}
|
||||
}
|
||||
|
||||
if (obj.forEach) {
|
||||
obj.forEach(function (v, k) {
|
||||
stringableKeys = stringableKeys && writer.isStringableKey(em, k);
|
||||
});
|
||||
return stringableKeys;
|
||||
} else {
|
||||
throw new Error("Cannot walk keys of object type " + handlers.constructor(obj).name);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns true if x is an Object instance from a different JavaScript
|
||||
* context.
|
||||
* @param x
|
||||
* @returns {boolean}
|
||||
*/
|
||||
writer.isForeignObject = function (x) {
|
||||
if (x.constructor["transit$isObject"]) {
|
||||
return true;
|
||||
}
|
||||
|
||||
var ret = x.constructor.toString();
|
||||
|
||||
ret = ret.substr('function '.length);
|
||||
ret = ret.substr(0, ret.indexOf('('));
|
||||
isObject = ret == "Object";
|
||||
|
||||
if (typeof Object.defineProperty != "undefined") {
|
||||
Object.defineProperty(x.constructor, "transit$isObject", {
|
||||
value: isObject,
|
||||
enumerable: false
|
||||
});
|
||||
} else {
|
||||
x.constructor["transit$isObject"] = isObject;
|
||||
}
|
||||
|
||||
return isObject;
|
||||
};
|
||||
|
||||
writer.emitMap = function (em, obj, skip, cache) {
|
||||
var arr = null, rep = null, tag = null, ks = null, i = 0;
|
||||
|
||||
if ((obj.constructor === Object) ||
|
||||
(obj.forEach != null) ||
|
||||
(em.handlerForForeign && writer.isForeignObject(obj))) {
|
||||
if (em.verbose) {
|
||||
if (obj.forEach != null) {
|
||||
if (writer.stringableKeys(em, obj)) {
|
||||
var ret = {};
|
||||
obj.forEach(function (v, k) {
|
||||
ret[writer.marshal(em, k, true, false)] = writer.marshal(em, v, false, cache);
|
||||
});
|
||||
return ret;
|
||||
} else {
|
||||
arr = em.unpack(obj);
|
||||
rep = [];
|
||||
tag = em.emitString(d.ESC_TAG, "cmap", "", true, cache);
|
||||
if (arr) {
|
||||
for (; i < arr.length; i += 2) {
|
||||
rep.push(writer.marshal(em, arr[i], false, false));
|
||||
rep.push(writer.marshal(em, arr[i + 1], false, cache));
|
||||
}
|
||||
} else {
|
||||
obj.forEach(function (v, k) {
|
||||
rep.push(writer.marshal(em, k, false, false));
|
||||
rep.push(writer.marshal(em, v, false, cache));
|
||||
});
|
||||
}
|
||||
ret = {};
|
||||
ret[tag] = rep;
|
||||
return ret;
|
||||
}
|
||||
} else {
|
||||
ks = util.objectKeys(obj);
|
||||
ret = {};
|
||||
for (; i < ks.length; i++) {
|
||||
ret[writer.marshal(em, ks[i], true, false)] = writer.marshal(em, obj[ks[i]], false, cache);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
} else {
|
||||
if (obj.forEach != null) {
|
||||
if (writer.stringableKeys(em, obj)) {
|
||||
arr = em.unpack(obj);
|
||||
ret = ["^ "];
|
||||
if (arr) {
|
||||
for (; i < arr.length; i += 2) {
|
||||
ret.push(writer.marshal(em, arr[i], true, cache));
|
||||
ret.push(writer.marshal(em, arr[i + 1], false, cache));
|
||||
}
|
||||
} else {
|
||||
obj.forEach(function (v, k) {
|
||||
ret.push(writer.marshal(em, k, true, cache));
|
||||
ret.push(writer.marshal(em, v, false, cache));
|
||||
});
|
||||
}
|
||||
return ret;
|
||||
} else {
|
||||
arr = em.unpack(obj);
|
||||
rep = [];
|
||||
tag = em.emitString(d.ESC_TAG, "cmap", "", true, cache);
|
||||
if (arr) {
|
||||
for (; i < arr.length; i += 2) {
|
||||
rep.push(writer.marshal(em, arr[i], false, cache));
|
||||
rep.push(writer.marshal(em, arr[i + 1], false, cache));
|
||||
}
|
||||
} else {
|
||||
obj.forEach(function (v, k) {
|
||||
rep.push(writer.marshal(em, k, false, cache));
|
||||
rep.push(writer.marshal(em, v, false, cache));
|
||||
});
|
||||
}
|
||||
return [tag, rep];
|
||||
}
|
||||
} else {
|
||||
ret = ["^ "];
|
||||
ks = util.objectKeys(obj);
|
||||
for (; i < ks.length; i++) {
|
||||
ret.push(writer.marshal(em, ks[i], true, cache));
|
||||
ret.push(writer.marshal(em, obj[ks[i]], false, cache));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
} else if (em.objectBuilder != null) {
|
||||
return em.objectBuilder(obj, function (k) {
|
||||
return writer.marshal(em, k, true, cache);
|
||||
},
|
||||
function (v) {
|
||||
return writer.marshal(em, v, false, cache);
|
||||
});
|
||||
} else {
|
||||
var name = handlers.constructor(obj).name,
|
||||
err = new Error("Cannot write " + name);
|
||||
err.data = {obj: obj, type: name};
|
||||
throw err;
|
||||
}
|
||||
};
|
||||
|
||||
writer.emitTaggedMap = function (em, tag, rep, skip, cache) {
|
||||
if (em.verbose) {
|
||||
var ret = {};
|
||||
ret[em.emitString(d.ESC_TAG, tag, "", true, cache)] = writer.marshal(em, rep, false, cache);
|
||||
return ret;
|
||||
} else {
|
||||
return [em.emitString(d.ESC_TAG, tag, "", true, cache), writer.marshal(em, rep, false, cache)];
|
||||
}
|
||||
};
|
||||
|
||||
writer.emitEncoded = function (em, h, tag, rep, obj, asMapKey, cache) {
|
||||
if (tag.length === 1) {
|
||||
if (typeof rep === "string") {
|
||||
return em.emitString(d.ESC, tag, rep, asMapKey, cache);
|
||||
} else if (asMapKey || em.preferStrings) {
|
||||
var vh = em.verbose && h.getVerboseHandler();
|
||||
if (vh) {
|
||||
tag = vh.tag(obj);
|
||||
rep = vh.stringRep(obj, vh);
|
||||
} else {
|
||||
rep = h.stringRep(obj, h);
|
||||
}
|
||||
if (rep !== null) {
|
||||
return em.emitString(d.ESC, tag, rep, asMapKey, cache);
|
||||
} else {
|
||||
var err = new Error("Tag \"" + tag + "\" cannot be encoded as string");
|
||||
err.data = {tag: tag, rep: rep, obj: obj};
|
||||
throw err;
|
||||
}
|
||||
} else {
|
||||
return writer.emitTaggedMap(em, tag, rep, asMapKey, cache);
|
||||
}
|
||||
} else {
|
||||
return writer.emitTaggedMap(em, tag, rep, asMapKey, cache);
|
||||
}
|
||||
};
|
||||
|
||||
writer.marshal = function (em, obj, asMapKey, cache) {
|
||||
var h = em.handler(obj) || (em.handlerForForeign ? em.handlerForForeign(obj, em.handlers) : null),
|
||||
tag = h ? h.tag(obj) : null,
|
||||
rep = h ? h.rep(obj) : null;
|
||||
|
||||
if (h != null && tag != null) {
|
||||
switch (tag) {
|
||||
case "_":
|
||||
return em.emitNil(asMapKey, cache);
|
||||
break;
|
||||
case "s":
|
||||
return em.emitString("", "", writer.escape(rep), asMapKey, cache);
|
||||
break;
|
||||
case "?":
|
||||
return em.emitBoolean(rep, asMapKey, cache);
|
||||
break;
|
||||
case "i":
|
||||
return em.emitInteger(rep, asMapKey, cache);
|
||||
break;
|
||||
case "d":
|
||||
return em.emitDouble(rep, asMapKey, cache);
|
||||
break;
|
||||
case "b":
|
||||
return em.emitBinary(rep, asMapKey, cache);
|
||||
break;
|
||||
case "'":
|
||||
return em.emitQuoted(em, rep, cache);
|
||||
break;
|
||||
case "array":
|
||||
return writer.emitArray(em, rep, asMapKey, cache);
|
||||
break;
|
||||
case "map":
|
||||
return writer.emitMap(em, rep, asMapKey, cache);
|
||||
break;
|
||||
default:
|
||||
return writer.emitEncoded(em, h, tag, rep, obj, asMapKey, cache);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
var name = handlers.constructor(obj).name,
|
||||
err = new Error("Cannot write " + name);
|
||||
err.data = {obj: obj, type: name};
|
||||
throw err;
|
||||
}
|
||||
};
|
||||
|
||||
writer.maybeQuoted = function (em, obj) {
|
||||
var h = em.handler(obj) || (em.handlerForForeign ? em.handlerForForeign(obj, em.handlers) : null);
|
||||
|
||||
if (h != null) {
|
||||
if (h.tag(obj).length === 1) {
|
||||
return types.quoted(obj);
|
||||
} else {
|
||||
return obj;
|
||||
}
|
||||
} else {
|
||||
var name = handlers.constructor(obj).name,
|
||||
err = new Error("Cannot write " + name);
|
||||
err.data = {obj: obj, type: name};
|
||||
throw err;
|
||||
}
|
||||
};
|
||||
|
||||
writer.marshalTop = function (em, obj, asMapKey, cache) {
|
||||
return JSON.stringify(writer.marshal(em, writer.maybeQuoted(em, obj), asMapKey, cache));
|
||||
};
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
writer.Writer = function Transit$Writer(marshaller, options) {
|
||||
this._marshaller = marshaller;
|
||||
this.options = options || {};
|
||||
if (this.options["cache"] === false) {
|
||||
this.cache = null;
|
||||
} else {
|
||||
this.cache = this.options["cache"] ? this.options["cache"] : new caching.WriteCache();
|
||||
}
|
||||
};
|
||||
|
||||
writer.Writer.prototype.marshaller = function () {
|
||||
return this._marshaller;
|
||||
};
|
||||
writer.Writer.prototype["marshaller"] = writer.Writer.prototype.marshaller;
|
||||
|
||||
writer.Writer.prototype.write = function (obj, opts) {
|
||||
var ret = null,
|
||||
ropts = opts || {},
|
||||
asMapKey = ropts["asMapKey"] || false,
|
||||
cache = this._marshaller.verbose ? false : this.cache;
|
||||
|
||||
if (ropts["marshalTop"] === false) {
|
||||
ret = writer.marshal(this._marshaller, obj, asMapKey, cache)
|
||||
} else {
|
||||
ret = writer.marshalTop(this._marshaller, obj, asMapKey, cache)
|
||||
}
|
||||
if (this.cache != null) {
|
||||
this.cache.clear();
|
||||
}
|
||||
return ret;
|
||||
};
|
||||
writer.Writer.prototype["write"] = writer.Writer.prototype.write;
|
||||
|
||||
writer.Writer.prototype.register = function (type, handler) {
|
||||
this._marshaller.registerHandler(type, handler);
|
||||
};
|
||||
writer.Writer.prototype["register"] = writer.Writer.prototype.register;
|
||||
|
||||
});
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,144 @@
|
|||
// Copyright 2014 Cognitect. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS-IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
goog.provide("com.cognitect.transit.util");
|
||||
goog.require("goog.object");
|
||||
|
||||
goog.scope(function () {
|
||||
|
||||
var util = com.cognitect.transit.util,
|
||||
gobject = goog.object;
|
||||
|
||||
if (typeof Object.keys != "undefined") {
|
||||
util.objectKeys = function (obj) {
|
||||
return Object.keys(obj);
|
||||
};
|
||||
} else {
|
||||
util.objectKeys = function (obj) {
|
||||
return gobject.getKeys(obj);
|
||||
};
|
||||
}
|
||||
|
||||
if (typeof Array.isArray != "undefined") {
|
||||
util.isArray = function (obj) {
|
||||
return Array.isArray(obj);
|
||||
};
|
||||
} else {
|
||||
util.isArray = function (obj) {
|
||||
return goog.typeOf(obj) === "array";
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {string}
|
||||
*/
|
||||
util.chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
|
||||
|
||||
util.randInt = function (ub) {
|
||||
return Math.round(Math.random() * ub);
|
||||
};
|
||||
|
||||
util.randHex = function () {
|
||||
return util.randInt(15).toString(16);
|
||||
};
|
||||
|
||||
util.randomUUID = function () {
|
||||
var rhex = (0x8 | (0x3 & util.randInt(14))).toString(16),
|
||||
ret = util.randHex() + util.randHex() + util.randHex() + util.randHex() +
|
||||
util.randHex() + util.randHex() + util.randHex() + util.randHex() + "-" +
|
||||
util.randHex() + util.randHex() + util.randHex() + util.randHex() + "-" +
|
||||
"4" + util.randHex() + util.randHex() + util.randHex() + "-" +
|
||||
rhex + util.randHex() + util.randHex() + util.randHex() + "-" +
|
||||
util.randHex() + util.randHex() + util.randHex() + util.randHex() +
|
||||
util.randHex() + util.randHex() + util.randHex() + util.randHex() +
|
||||
util.randHex() + util.randHex() + util.randHex() + util.randHex();
|
||||
return ret;
|
||||
};
|
||||
|
||||
// https://github.com/davidchambers/Base64.js
|
||||
|
||||
util.btoa = function (input) {
|
||||
if (typeof btoa != "undefined") {
|
||||
return btoa(input);
|
||||
} else {
|
||||
var str = String(input);
|
||||
for (
|
||||
var block, charCode, idx = 0, map = util.chars, output = '';
|
||||
str.charAt(idx | 0) || (map = '=', idx % 1);
|
||||
output += map.charAt(63 & block >> 8 - idx % 1 * 8)
|
||||
) {
|
||||
charCode = str.charCodeAt(idx += 3 / 4);
|
||||
if (charCode > 0xFF) {
|
||||
throw new Error("'btoa' failed: The string to be encoded contains characters outside of the Latin1 range.");
|
||||
}
|
||||
block = block << 8 | charCode;
|
||||
}
|
||||
return output;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @suppress {uselessCode}
|
||||
*/
|
||||
util.atob = function (input) {
|
||||
if (typeof atob != "undefined") {
|
||||
return atob(input);
|
||||
} else {
|
||||
var str = String(input).replace(/=+$/, '');
|
||||
if (str.length % 4 == 1) {
|
||||
throw new Error("'atob' failed: The string to be decoded is not correctly encoded.");
|
||||
}
|
||||
for (
|
||||
var bc = 0, bs, buffer, idx = 0, output = '';
|
||||
buffer = str.charAt(idx++);
|
||||
~buffer && (bs = bc % 4 ? bs * 64 + buffer : buffer,
|
||||
bc++ % 4) ? output += String.fromCharCode(255 & bs >> (-2 * bc & 6)) : 0
|
||||
) {
|
||||
buffer = util.chars.indexOf(buffer);
|
||||
}
|
||||
return output;
|
||||
}
|
||||
};
|
||||
|
||||
util.Uint8ToBase64 = function (u8Arr) {
|
||||
var CHUNK_SIZE = 0x8000,
|
||||
index = 0,
|
||||
length = u8Arr.length,
|
||||
result = '',
|
||||
slice = null;
|
||||
|
||||
while (index < length) {
|
||||
slice = u8Arr.subarray(index, Math.min(index + CHUNK_SIZE, length));
|
||||
result += String.fromCharCode.apply(null, slice);
|
||||
index += CHUNK_SIZE;
|
||||
}
|
||||
|
||||
return util.btoa(result);
|
||||
};
|
||||
|
||||
util.Base64ToUint8 = function (base64) {
|
||||
var binary_string = util.atob(base64),
|
||||
len = binary_string.length,
|
||||
bytes = new Uint8Array(len);
|
||||
|
||||
for (var i = 0; i < len; i++) {
|
||||
var ascii = binary_string.charCodeAt(i);
|
||||
bytes[i] = ascii;
|
||||
}
|
||||
|
||||
return bytes;
|
||||
};
|
||||
|
||||
});
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue