diff options
author | Fabrice Bellard <fabrice@bellard.org> | 2023-12-27 17:19:25 +0100 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2023-12-28 22:14:38 +0100 |
commit | ab87f26797cbef4b228d4b2399861d2f86766ff9 (patch) | |
tree | 1f1700e7eb60635e87cdfa97cb141069f18be2c4 /lib | |
parent | 5f6d7529f6fd614de3449ac917cc20aa1d031a16 (diff) | |
download | chawan-ab87f26797cbef4b228d4b2399861d2f86766ff9.tar.gz |
added Promise.withResolvers
Diffstat (limited to 'lib')
-rw-r--r-- | lib/quickjs/quickjs.c | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/lib/quickjs/quickjs.c b/lib/quickjs/quickjs.c index fe37a64f..bf87bcee 100644 --- a/lib/quickjs/quickjs.c +++ b/lib/quickjs/quickjs.c @@ -47780,17 +47780,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); @@ -47805,7 +47802,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, @@ -48295,7 +48291,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), }; |