You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/jtk_dvlp/async.cljc
+31-1
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
(nsjtk-dvlp.async
2
2
(:refer-clojure
3
-
:exclude [map reduce into])
3
+
:exclude [map pmap amap reduce into])
4
4
5
5
#?(:cljs
6
6
(:require-macros
@@ -116,3 +116,33 @@
116
116
"Like `core.async/into` but carries thrown exception (will convert to `ExceptionInfo`) as result."
117
117
[coll ch]
118
118
(reduce conj coll ch))
119
+
120
+
(defnsmap
121
+
"Applies async function `<f` on every item of seqs `xs` *chaining its execution to make sure its run sequentially*. All seqs of `xs` must have the same length. Returns vector of all results applying `<f`. Supports error handling.
122
+
123
+
Also see `amap`"
124
+
[<f & xs]
125
+
(go-loop [result [], xs xs]
126
+
(if (ffirst xs)
127
+
(do
128
+
(let [next-result
129
+
(->> xs
130
+
(mapv first)
131
+
(apply <f)
132
+
(<!))]
133
+
134
+
(recur
135
+
(conj result next-result)
136
+
(mapv next xs))))
137
+
138
+
result)))
139
+
140
+
(defchainsmap)
141
+
142
+
(defn-amap
143
+
"Applies async function `<f` on every item of seqs `xs`. All seqs of `xs` must have the same length. Returns vector of all results applying `<f`. Supports error handling.
0 commit comments