Implement Promise.withResolvers (#14)
This commit is contained in:
parent
99eb81e1a6
commit
18eb603e0d
2 changed files with 7 additions and 12 deletions
15
quickjs.c
15
quickjs.c
|
@ -46905,19 +46905,15 @@ static JSValue js_promise_resolve(JSContext *ctx, JSValueConst this_val,
|
||||||
return result_promise;
|
return result_promise;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
static JSValue js_promise_withResolvers(JSContext *ctx, JSValueConst this_val,
|
||||||
static JSValue js_promise___newPromiseCapability(JSContext *ctx,
|
|
||||||
JSValueConst this_val,
|
|
||||||
int argc, JSValueConst *argv)
|
int argc, JSValueConst *argv)
|
||||||
{
|
{
|
||||||
JSValue result_promise, resolving_funcs[2], obj;
|
JSValue result_promise, resolving_funcs[2], obj;
|
||||||
JSValueConst ctor;
|
if (!JS_IsObject(this_val))
|
||||||
ctor = argv[0];
|
|
||||||
if (!JS_IsObject(ctor))
|
|
||||||
return JS_ThrowTypeErrorNotAnObject(ctx);
|
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))
|
if (JS_IsException(result_promise))
|
||||||
return result_promise;
|
return JS_EXCEPTION;
|
||||||
obj = JS_NewObject(ctx);
|
obj = JS_NewObject(ctx);
|
||||||
if (JS_IsException(obj)) {
|
if (JS_IsException(obj)) {
|
||||||
JS_FreeValue(ctx, resolving_funcs[0]);
|
JS_FreeValue(ctx, resolving_funcs[0]);
|
||||||
|
@ -46930,7 +46926,6 @@ static JSValue js_promise___newPromiseCapability(JSContext *ctx,
|
||||||
JS_DefinePropertyValue(ctx, obj, JS_ATOM_reject, resolving_funcs[1], JS_PROP_C_W_E);
|
JS_DefinePropertyValue(ctx, obj, JS_ATOM_reject, resolving_funcs[1], JS_PROP_C_W_E);
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
static __exception int remainingElementsCount_add(JSContext *ctx,
|
static __exception int remainingElementsCount_add(JSContext *ctx,
|
||||||
JSValueConst resolve_element_env,
|
JSValueConst resolve_element_env,
|
||||||
|
@ -47420,7 +47415,7 @@ static const JSCFunctionListEntry js_promise_funcs[] = {
|
||||||
JS_CFUNC_MAGIC_DEF("allSettled", 1, js_promise_all, PROMISE_MAGIC_allSettled ),
|
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_MAGIC_DEF("any", 1, js_promise_all, PROMISE_MAGIC_any ),
|
||||||
JS_CFUNC_DEF("race", 1, js_promise_race ),
|
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),
|
JS_CGETSET_DEF("[Symbol.species]", js_get_this, NULL),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -141,7 +141,7 @@ Object.is
|
||||||
optional-catch-binding
|
optional-catch-binding
|
||||||
optional-chaining
|
optional-chaining
|
||||||
Promise
|
Promise
|
||||||
promise-with-resolvers=skip
|
promise-with-resolvers
|
||||||
Promise.allSettled
|
Promise.allSettled
|
||||||
Promise.any
|
Promise.any
|
||||||
Promise.prototype.finally
|
Promise.prototype.finally
|
||||||
|
|
Loading…
Reference in a new issue