Skip to content

Commit

Permalink
builtins/promise: impl withResolvers
Browse files Browse the repository at this point in the history
test262: 42.53% | πŸ§ͺ 48414 | 🀠 20591 (+2) | ❌ 6381 (+2) | πŸ’€ 15239 (-4) | πŸ—οΈ 64 | πŸ’₯ 296 | ⏰ 28 | πŸ“ 5815
  • Loading branch information
CanadaHonk committed Sep 11, 2024
1 parent 4c42fe0 commit b478d66
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
15 changes: 14 additions & 1 deletion compiler/builtins/promise.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,6 @@ export const Promise = function (executor: any): void {
if (Porffor.rawType(executor) != Porffor.TYPES.function) throw new TypeError('Promise executor is not a function');

const obj: any[] = __Porffor_promise_create();

activePromise = obj;

try {
Expand All @@ -203,6 +202,20 @@ export const Promise = function (executor: any): void {
return pro;
};

export const __Promise_withResolvers = (): Promise => {
const obj: any[] = __Porffor_promise_create();
activePromise = obj;

const promise: Promise = obj;
const out: object = Porffor.allocate();
out.promise = promise;

out.resolve = __Porffor_promise_resolveActive;
out.reject = __Porffor_promise_rejectActive;

return out;
};

export const __Promise_resolve = (value: any): Promise => {
const obj: any[] = __Porffor_promise_create();

Expand Down
Loading

0 comments on commit b478d66

Please sign in to comment.