File tree Expand file tree Collapse file tree 2 files changed +12
-12
lines changed Expand file tree Collapse file tree 2 files changed +12
-12
lines changed Original file line number Diff line number Diff line change 552
552
[& exprs]
553
553
(condp = (count exprs)
554
554
0 `(impl/resolved nil )
555
- 1 `(pt/-promise ~(first exprs))
555
+ 1 `(impl/coerce ~(first exprs))
556
556
(reduce (fn [acc e]
557
- `(pt/-mcat (pt/-promise ~e) (fn [_#] ~acc)))
558
- `(pt/-promise ~(last exprs))
557
+ `(pt/-mcat (impl/coerce ~e) (fn [_#] ~acc)))
558
+ `(impl/coerce ~(last exprs))
559
559
(reverse (butlast exprs)))))
560
560
561
561
(defmacro do
564
564
expression."
565
565
[& exprs]
566
566
`(pt/-mcat
567
- (pt/-promise nil )
567
+ (impl/resolved nil )
568
568
(fn [_#]
569
569
(promesa.core/do* ~@exprs))))
570
570
580
580
(assert (even? (count bindings)) (str " Uneven binding vector: " bindings))
581
581
(c/->> (reverse (partition 2 bindings))
582
582
(reduce (fn [acc [l r]]
583
- `(pt/-mcat (pt/-promise ~r) (fn [~l] ~acc)))
583
+ `(pt/-mcat (impl/coerce ~r) (fn [~l] ~acc)))
584
584
`(do* ~@body))))
585
585
586
586
(defmacro let
589
589
[bindings & body]
590
590
(if (seq bindings)
591
591
`(pt/-mcat
592
- (pt/-promise nil )
592
+ (impl/resolved nil )
593
593
(fn [_#] (promesa.core/let* ~bindings ~@body)))
594
594
`(promesa.core/do ~@body)))
595
595
599
599
[bindings & body]
600
600
(assert (even? (count bindings)) (str " Uneven binding vector: " bindings))
601
601
`(pt/-mcat
602
- (pt/-promise nil )
602
+ (impl/resolved nil )
603
603
(fn [_#]
604
604
~(c/let [bindings (partition 2 bindings)]
605
605
`(c/-> (all ~(mapv second bindings))
Original file line number Diff line number Diff line change 54
54
(.completeExceptionally ^CompletableFuture p v)
55
55
p)))
56
56
57
- #?( :cljs
58
- ( defn coerce
59
- " Coerce a thenable to built-in promise impl type. "
60
- [v]
61
- ( impl/coerce v)))
57
+ ( defn coerce
58
+ [v]
59
+ ( if ( promise? v)
60
+ v
61
+ ( resolved v)))
62
62
63
63
(defn all
64
64
[promises]
You can’t perform that action at this time.
0 commit comments