Skip to content

Commit

Permalink
feat: toClrType auto convert Promise to Task
Browse files Browse the repository at this point in the history
  • Loading branch information
LazuliKao committed Aug 15, 2023
1 parent 22cd0d3 commit c1c481c
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/QuickJS/Extensions/JsValueExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Text.Json;
using System.Text.Json.Nodes;
using Hosihikari.VanillaScript.QuickJS.Exceptions;
using Hosihikari.VanillaScript.QuickJS.Helper;
using Hosihikari.VanillaScript.QuickJS.Types;
using Hosihikari.VanillaScript.QuickJS.Wrapper;
using Hosihikari.VanillaScript.QuickJS.Wrapper.ClrProxy;
Expand Down Expand Up @@ -429,6 +430,10 @@ or JsTag.Undefined
//case JsTag.Object when Native.JS_IsArray(ctx, @this):
// throw new NotImplementedException("js array to clr not impl");
case JsTag.Object:
if (@this.IsPromise(ctx))
{
return JsPromiseHelper.ConvertPromiseToTask(ctx, @this);
}
if (
ClrProxyBase.TryGetInstance(@this, out var item)
&& item is ClrInstanceProxy { Instance: var instance }
Expand Down

0 comments on commit c1c481c

Please sign in to comment.