mirror of
https://github.com/denoland/deno.git
synced 2025-08-30 07:18:02 +00:00
refactor: port more ops to ensureFastOps()
(#22046)
This commit is contained in:
parent
01b6e38baf
commit
6238b0a457
3 changed files with 29 additions and 25 deletions
|
@ -7,11 +7,12 @@
|
|||
// TODO(petamoriken): enable prefer-primordials for node polyfills
|
||||
// deno-lint-ignore-file prefer-primordials
|
||||
|
||||
import { core } from "ext:core/mod.js";
|
||||
const {
|
||||
op_node_is_promise_rejected,
|
||||
} = core.ensureFastOps();
|
||||
import { validateFunction } from "ext:deno_node/internal/validators.mjs";
|
||||
|
||||
const { core } = globalThis.__bootstrap;
|
||||
const { ops } = core;
|
||||
|
||||
function assert(cond: boolean) {
|
||||
if (!cond) throw new Error("Assertion failed");
|
||||
}
|
||||
|
@ -57,7 +58,7 @@ function setPromiseHooks() {
|
|||
};
|
||||
const after = (promise: Promise<unknown>) => {
|
||||
popAsyncFrame();
|
||||
if (!ops.op_node_is_promise_rejected(promise)) {
|
||||
if (!op_node_is_promise_rejected(promise)) {
|
||||
// @ts-ignore promise async context
|
||||
promise[asyncContext] = undefined;
|
||||
}
|
||||
|
@ -65,7 +66,7 @@ function setPromiseHooks() {
|
|||
const resolve = (promise: Promise<unknown>) => {
|
||||
const currentFrame = AsyncContextFrame.current();
|
||||
if (
|
||||
!currentFrame.isRoot() && ops.op_node_is_promise_rejected(promise) &&
|
||||
!currentFrame.isRoot() && op_node_is_promise_rejected(promise) &&
|
||||
typeof promise[asyncContext] === "undefined"
|
||||
) {
|
||||
AsyncContextFrame.attachContext(promise);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue