Skip to content

Commit

Permalink
fix: use primordials
Browse files Browse the repository at this point in the history
  • Loading branch information
lbguilherme committed Aug 16, 2022
1 parent cff12d7 commit d73be8b
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions core/01_core.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,29 +242,29 @@
};

function setPromiseHooks(init, before, after, resolve) {
if (init) promiseHooks.init.push(init);
if (before) promiseHooks.before.push(before);
if (after) promiseHooks.after.push(after);
if (resolve) promiseHooks.resolve.push(resolve);
if (init) ArrayPrototypePush(promiseHooks.init, init);
if (before) ArrayPrototypePush(promiseHooks.before, before);
if (after) ArrayPrototypePush(promiseHooks.after, after);
if (resolve) ArrayPrototypePush(promiseHooks.resolve, resolve);

if (!promiseHooks.hasBeenSet) {
promiseHooks.hasBeenSet = true;

ops.op_set_promise_hooks((promise, parentPromise) => {
for (const cb of promiseHooks.init) {
cb(promise, parentPromise);
for (let i = 0; i < promiseHooks.init.length; ++i) {
promiseHooks.init[i](promise, parentPromise);
}
}, (promise) => {
for (const cb of promiseHooks.before) {
cb(promise);
for (let i = 0; i < promiseHooks.before.length; ++i) {
promiseHooks.before[i](promise);
}
}, (promise) => {
for (const cb of promiseHooks.after) {
cb(promise);
for (let i = 0; i < promiseHooks.after.length; ++i) {
promiseHooks.after[i](promise);
}
}, (promise) => {
for (const cb of promiseHooks.resolve) {
cb(promise);
for (let i = 0; i < promiseHooks.resolve.length; ++i) {
promiseHooks.resolve[i](promise);
}
});
}
Expand Down

0 comments on commit d73be8b

Please sign in to comment.