Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Promise.withResolvers #14

Merged
merged 1 commit into from
Nov 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 6 additions & 11 deletions quickjs.c
Original file line number Diff line number Diff line change
Expand Up @@ -46841,19 +46841,15 @@ 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;
return JS_EXCEPTION;
obj = JS_NewObject(ctx);
if (JS_IsException(obj)) {
JS_FreeValue(ctx, resolving_funcs[0]);
Expand All @@ -46866,7 +46862,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,
Expand Down Expand Up @@ -47356,7 +47351,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),
};

Expand Down
2 changes: 1 addition & 1 deletion test262.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down