]> git.kaiwu.me - quickjs.git/commitdiff
added Promise.withResolvers
authorFabrice Bellard <fabrice@bellard.org>
Wed, 27 Dec 2023 16:19:25 +0000 (17:19 +0100)
committerFabrice Bellard <fabrice@bellard.org>
Wed, 27 Dec 2023 16:19:25 +0000 (17:19 +0100)
TODO
quickjs.c
test262.conf

diff --git a/TODO b/TODO
index a640d0110a93bc2a9235d8db859addc847ebe40b..65372b865efa99cb9042ad8a33577985bc3b131d 100644 (file)
--- a/TODO
+++ b/TODO
@@ -63,5 +63,5 @@ Optimization ideas:
 Test262o:   0/11262 errors, 463 excluded
 Test262o commit: 7da91bceb9ce7613f87db47ddd1292a2dda58b42 (es5-tests branch)
 
-Result: 16/76707 errors, 1497 excluded, 8237 skipped
+Result: 16/76719 errors, 1497 excluded, 8231 skipped
 Test262 commit: 6cbb6da9473c56d95358d8e679c5a6d2b4574efb
index 71a93f163c31fe6ec0327985ed0495bb8d6dfb2d..8e9750dcebd2fa607f74484449f5b43b9f48b4c2 100644 (file)
--- a/quickjs.c
+++ b/quickjs.c
@@ -47662,17 +47662,14 @@ static JSValue js_promise_resolve(JSContext *ctx, JSValueConst this_val,
     return result_promise;
 }
 
-#if 0
-static JSValue js_promise___newPromiseCapability(JSContext *ctx,
-                                                 JSValueConst this_val,
-                                                 int argc, JSValueConst *argv)
+static JSValue js_promise_withResolvers(JSContext *ctx,
+                                        JSValueConst this_val,
+                                        int argc, JSValueConst *argv)
 {
     JSValue result_promise, resolving_funcs[2], obj;
-    JSValueConst ctor;
-    ctor = argv[0];
-    if (!JS_IsObject(ctor))
+    if (!JS_IsObject(this_val))
         return JS_ThrowTypeErrorNotAnObject(ctx);
-    result_promise = js_new_promise_capability(ctx, resolving_funcs, ctor);
+    result_promise = js_new_promise_capability(ctx, resolving_funcs, this_val);
     if (JS_IsException(result_promise))
         return result_promise;
     obj = JS_NewObject(ctx);
@@ -47687,7 +47684,6 @@ static JSValue js_promise___newPromiseCapability(JSContext *ctx,
     JS_DefinePropertyValue(ctx, obj, JS_ATOM_reject, resolving_funcs[1], JS_PROP_C_W_E);
     return obj;
 }
-#endif
 
 static __exception int remainingElementsCount_add(JSContext *ctx,
                                                   JSValueConst resolve_element_env,
@@ -48177,7 +48173,7 @@ static const JSCFunctionListEntry js_promise_funcs[] = {
     JS_CFUNC_MAGIC_DEF("allSettled", 1, js_promise_all, PROMISE_MAGIC_allSettled ),
     JS_CFUNC_MAGIC_DEF("any", 1, js_promise_all, PROMISE_MAGIC_any ),
     JS_CFUNC_DEF("race", 1, js_promise_race ),
-    //JS_CFUNC_DEF("__newPromiseCapability", 1, js_promise___newPromiseCapability ),
+    JS_CFUNC_DEF("withResolvers", 0, js_promise_withResolvers ),
     JS_CGETSET_DEF("[Symbol.species]", js_get_this, NULL),
 };
 
index e3183bd9a41fb95b8ef1b1331389fdf0007e3a3b..de8eca44720c073a207f48768893f23e91ce78ce 100644 (file)
@@ -141,7 +141,7 @@ Object.is
 optional-catch-binding
 optional-chaining
 Promise
-promise-with-resolvers=skip
+promise-with-resolvers
 Promise.allSettled
 Promise.any
 Promise.prototype.finally