Clean up database interop
This commit is contained in:
parent
905fe2bd88
commit
2b78afde38
2 changed files with 17 additions and 20 deletions
|
|
@ -103,13 +103,13 @@
|
|||
Takes a transducer `xform`, a reducing function `rf` and an initial `init`.
|
||||
If no `init` is given, it will default to `(rf)`. If no `rf` is given, the
|
||||
resulting value will be a persistent vector containing the result of all steps."
|
||||
([cursor-req xform]
|
||||
([xform cursor-req]
|
||||
; optimization: work with a transient vector before returning the final result
|
||||
(-> (transduce-cursor cursor-req xform conj! (transient []))
|
||||
(-> (transduce-cursor xform conj! (transient []) cursor-req)
|
||||
(.then persistent!)))
|
||||
([cursor-req xform rf]
|
||||
(transduce-cursor cursor-req xform rf (rf)))
|
||||
([cursor-req xform rf init]
|
||||
([xform rf cursor-req]
|
||||
(transduce-cursor xform rf (rf) cursor-req))
|
||||
([xform rf init cursor-req]
|
||||
(let [result (volatile! init)
|
||||
xform (xform rf)]
|
||||
(js/Promise.
|
||||
|
|
@ -121,14 +121,15 @@
|
|||
; to avoid unnecessary conversion costs.
|
||||
(let [step (xform @result (.-value cursor))]
|
||||
(if (reduced? step)
|
||||
(do
|
||||
(vreset! result @step)
|
||||
(resolve @result))
|
||||
(resolve @step)
|
||||
(do
|
||||
(vreset! result step)
|
||||
(.continue cursor))))
|
||||
(resolve @result)))))))))
|
||||
|
||||
(defn first-result [xform cursor-req]
|
||||
(transduce-cursor (comp xform (take 1)) (fn [_ x] x) cursor-req))
|
||||
|
||||
(def all (js/IDBKeyRange.lowerBound ""))
|
||||
|
||||
(comment
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue