From a9b2aa45656b97a19598cce2868d54cfabc7707c Mon Sep 17 00:00:00 2001 From: Ian Fernandez Date: Thu, 19 Dec 2024 16:48:27 -0300 Subject: [PATCH 1/2] Add babashka compatibility --- src/sieppari/async.cljc | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/src/sieppari/async.cljc b/src/sieppari/async.cljc index 724b65e..d55c29e 100644 --- a/src/sieppari/async.cljc +++ b/src/sieppari/async.cljc @@ -11,12 +11,6 @@ (catch [c f]) #?(:clj (await [t]))) -#?(:clj - (deftype FunctionWrapper [f] - Function - (apply [_ v] - (f v)))) - #?(:clj (extend-protocol AsyncContext Object @@ -26,9 +20,9 @@ #?(:cljs (extend-protocol AsyncContext - default - (async? [_] false) - (continue [t f] (f t)))) + default + (async? [_] false) + (continue [t f] (f t)))) #?(:clj (extend-protocol AsyncContext @@ -45,22 +39,26 @@ (async? [_] true) (continue [this f] (.thenApply ^CompletionStage this - ^Function (->FunctionWrapper f))) + ^Function (reify Function + (apply [_ v] + (f v))))) (catch [this f] (letfn [(handler [e] - (if (instance? CompletionException e) + (if (instance? CompletionException e) (f (.getCause ^Exception e)) (f e)))] (.exceptionally ^CompletionStage this - ^Function (->FunctionWrapper handler)))) + ^Function (reify Function + (apply [_ v] + (handler v)))))) (await [this] (deref this)))) #?(:cljs (extend-protocol AsyncContext - js/Promise - (async? [_] true) - (continue [t f] (.then t f)) - (catch [t f] (.catch t f)))) + js/Promise + (async? [_] true) + (continue [t f] (.then t f)) + (catch [t f] (.catch t f)))) From 38391917429543ea122be2fafd25d911644d2b89 Mon Sep 17 00:00:00 2001 From: Tommi Reiman Date: Fri, 20 Dec 2024 09:28:48 +0200 Subject: [PATCH 2/2] Update async.cljc format --- src/sieppari/async.cljc | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/sieppari/async.cljc b/src/sieppari/async.cljc index d55c29e..2d95eb8 100644 --- a/src/sieppari/async.cljc +++ b/src/sieppari/async.cljc @@ -20,9 +20,9 @@ #?(:cljs (extend-protocol AsyncContext - default - (async? [_] false) - (continue [t f] (f t)))) + default + (async? [_] false) + (continue [t f] (f t)))) #?(:clj (extend-protocol AsyncContext @@ -58,7 +58,7 @@ #?(:cljs (extend-protocol AsyncContext - js/Promise - (async? [_] true) - (continue [t f] (.then t f)) - (catch [t f] (.catch t f)))) + js/Promise + (async? [_] true) + (continue [t f] (.then t f)) + (catch [t f] (.catch t f))))