diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2024-01-29 22:02:26 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-29 22:02:26 +0100 |
commit | 345423cf7697326258ce8b32f681910f4a2f77de (patch) | |
tree | 484dd157be01e3dc0d4f34f28526dac1804d0250 /ext/node | |
parent | 909986fa6ed3404e76590438b387391a6c213e46 (diff) |
refactor: Use virtul ops module (#22175)
Follow up to #22157.
This leaves us with 4 usages of `ensureFastOps()` in `deno` itself.
There's also about 150 usages of `Deno.core.ops.<op_name>` left as well.
Diffstat (limited to 'ext/node')
-rw-r--r-- | ext/node/polyfills/01_require.js | 6 | ||||
-rw-r--r-- | ext/node/polyfills/_util/os.ts | 5 | ||||
-rw-r--r-- | ext/node/polyfills/child_process.ts | 6 | ||||
-rw-r--r-- | ext/node/polyfills/http.ts | 8 | ||||
-rw-r--r-- | ext/node/polyfills/internal/console/constructor.mjs | 5 | ||||
-rw-r--r-- | ext/node/polyfills/internal/crypto/_randomFill.mjs | 5 | ||||
-rw-r--r-- | ext/node/polyfills/internal/crypto/diffiehellman.ts | 5 | ||||
-rw-r--r-- | ext/node/polyfills/internal/crypto/keygen.ts | 7 | ||||
-rw-r--r-- | ext/node/polyfills/internal/crypto/random.ts | 6 | ||||
-rw-r--r-- | ext/node/polyfills/internal_binding/constants.ts | 5 | ||||
-rw-r--r-- | ext/node/polyfills/process.ts | 5 | ||||
-rw-r--r-- | ext/node/polyfills/tty.js | 6 | ||||
-rw-r--r-- | ext/node/polyfills/worker_threads.ts | 4 |
13 files changed, 22 insertions, 51 deletions
diff --git a/ext/node/polyfills/01_require.js b/ext/node/polyfills/01_require.js index 9d0258e0b..81af7062a 100644 --- a/ext/node/polyfills/01_require.js +++ b/ext/node/polyfills/01_require.js @@ -4,6 +4,7 @@ import { core, internals, primordials } from "ext:core/mod.js"; import { + op_napi_open, op_require_as_file_path, op_require_break_on_next_statement, op_require_init_paths, @@ -16,6 +17,7 @@ import { op_require_path_is_absolute, op_require_path_resolve, op_require_proxy_path, + op_require_read_closest_package_json, op_require_read_file, op_require_read_package_scope, op_require_real_path, @@ -27,10 +29,6 @@ import { op_require_try_self_parent_path, } from "ext:core/ops"; const { - op_napi_open, - op_require_read_closest_package_json, -} = core.ensureFastOps(true); -const { ArrayIsArray, ArrayPrototypeIncludes, ArrayPrototypeIndexOf, diff --git a/ext/node/polyfills/_util/os.ts b/ext/node/polyfills/_util/os.ts index 8a3d9edf4..421d5d9da 100644 --- a/ext/node/polyfills/_util/os.ts +++ b/ext/node/polyfills/_util/os.ts @@ -1,9 +1,6 @@ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. -import { core } from "ext:core/mod.js"; -const { - op_node_build_os, -} = core.ensureFastOps(true); +import { op_node_build_os } from "ext:core/ops"; export type OSType = | "windows" diff --git a/ext/node/polyfills/child_process.ts b/ext/node/polyfills/child_process.ts index 1d070d1ef..2182361e9 100644 --- a/ext/node/polyfills/child_process.ts +++ b/ext/node/polyfills/child_process.ts @@ -6,14 +6,12 @@ // TODO(petamoriken): enable prefer-primordials for node polyfills // deno-lint-ignore-file prefer-primordials -import { core, internals } from "ext:core/mod.js"; +import { internals } from "ext:core/mod.js"; import { op_bootstrap_unstable_args, op_node_child_ipc_pipe, -} from "ext:core/ops"; -const { op_npm_process_state, -} = core.ensureFastOps(true); +} from "ext:core/ops"; import { ChildProcess, diff --git a/ext/node/polyfills/http.ts b/ext/node/polyfills/http.ts index d3d51a324..0c6501d87 100644 --- a/ext/node/polyfills/http.ts +++ b/ext/node/polyfills/http.ts @@ -4,11 +4,11 @@ // deno-lint-ignore-file prefer-primordials import { core } from "ext:core/mod.js"; -import { op_fetch_response_upgrade, op_node_http_request } from "ext:core/ops"; -// TODO(bartlomieju): this ops is also used in `ext/fetch/26_fetch.js`. -const { +import { + op_fetch_response_upgrade, op_fetch_send, -} = core.ensureFastOps(true); + op_node_http_request, +} from "ext:core/ops"; import { TextEncoder } from "ext:deno_web/08_text_encoding.js"; import { setTimeout } from "ext:deno_web/02_timers.js"; diff --git a/ext/node/polyfills/internal/console/constructor.mjs b/ext/node/polyfills/internal/console/constructor.mjs index 45bca6675..caf6d144d 100644 --- a/ext/node/polyfills/internal/console/constructor.mjs +++ b/ext/node/polyfills/internal/console/constructor.mjs @@ -4,10 +4,7 @@ // TODO(petamoriken): enable prefer-primordials for node polyfills // deno-lint-ignore-file prefer-primordials -import { core } from "ext:core/mod.js"; -const { - op_preview_entries, -} = core.ensureFastOps(true); +import { op_preview_entries } from "ext:core/ops"; // Mock trace for now const trace = () => {}; diff --git a/ext/node/polyfills/internal/crypto/_randomFill.mjs b/ext/node/polyfills/internal/crypto/_randomFill.mjs index cb61e27ef..5de756536 100644 --- a/ext/node/polyfills/internal/crypto/_randomFill.mjs +++ b/ext/node/polyfills/internal/crypto/_randomFill.mjs @@ -3,11 +3,10 @@ // TODO(petamoriken): enable prefer-primordials for node polyfills // deno-lint-ignore-file prefer-primordials -import { core } from "ext:core/mod.js"; -const { +import { op_node_generate_secret, op_node_generate_secret_async, -} = core.ensureFastOps(true); +} from "ext:core/ops"; import { MAX_SIZE as kMaxUint32, diff --git a/ext/node/polyfills/internal/crypto/diffiehellman.ts b/ext/node/polyfills/internal/crypto/diffiehellman.ts index bba01e2c4..4b105e575 100644 --- a/ext/node/polyfills/internal/crypto/diffiehellman.ts +++ b/ext/node/polyfills/internal/crypto/diffiehellman.ts @@ -4,17 +4,14 @@ // TODO(petamoriken): enable prefer-primordials for node polyfills // deno-lint-ignore-file prefer-primordials -import { core } from "ext:core/mod.js"; import { op_node_dh_compute_secret, op_node_dh_generate2, op_node_ecdh_compute_public_key, op_node_ecdh_compute_secret, op_node_ecdh_generate_keys, -} from "ext:core/ops"; -const { op_node_gen_prime, -} = core.ensureFastOps(true); +} from "ext:core/ops"; import { notImplemented } from "ext:deno_node/_utils.ts"; import { diff --git a/ext/node/polyfills/internal/crypto/keygen.ts b/ext/node/polyfills/internal/crypto/keygen.ts index cdb94d222..f3263aecf 100644 --- a/ext/node/polyfills/internal/crypto/keygen.ts +++ b/ext/node/polyfills/internal/crypto/keygen.ts @@ -29,7 +29,6 @@ import { import { Buffer } from "node:buffer"; import { KeyFormat, KeyType } from "ext:deno_node/internal/crypto/types.ts"; -import { core } from "ext:core/mod.js"; import { op_node_dh_generate, op_node_dh_generate_async, @@ -43,13 +42,11 @@ import { op_node_ed25519_generate_async, op_node_generate_rsa, op_node_generate_rsa_async, + op_node_generate_secret, + op_node_generate_secret_async, op_node_x25519_generate, op_node_x25519_generate_async, } from "ext:core/ops"; -const { - op_node_generate_secret, - op_node_generate_secret_async, -} = core.ensureFastOps(true); function validateGenerateKey( type: "hmac" | "aes", diff --git a/ext/node/polyfills/internal/crypto/random.ts b/ext/node/polyfills/internal/crypto/random.ts index 0c8273bdf..4219414dc 100644 --- a/ext/node/polyfills/internal/crypto/random.ts +++ b/ext/node/polyfills/internal/crypto/random.ts @@ -4,18 +4,16 @@ // TODO(petamoriken): enable prefer-primordials for node polyfills // deno-lint-ignore-file prefer-primordials -import { core, primordials } from "ext:core/mod.js"; +import { primordials } from "ext:core/mod.js"; import { op_node_check_prime, op_node_check_prime_async, op_node_check_prime_bytes, op_node_check_prime_bytes_async, + op_node_gen_prime, op_node_gen_prime_async, } from "ext:core/ops"; const { - op_node_gen_prime, -} = core.ensureFastOps(true); -const { StringPrototypePadStart, StringPrototypeToString, } = primordials; diff --git a/ext/node/polyfills/internal_binding/constants.ts b/ext/node/polyfills/internal_binding/constants.ts index 4a6a90608..ccb0ba570 100644 --- a/ext/node/polyfills/internal_binding/constants.ts +++ b/ext/node/polyfills/internal_binding/constants.ts @@ -1,9 +1,6 @@ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. -import { core } from "ext:core/mod.js"; -const { - op_node_build_os, -} = core.ensureFastOps(true); +import { op_node_build_os } from "ext:core/ops"; let os: { dlopen: { diff --git a/ext/node/polyfills/process.ts b/ext/node/polyfills/process.ts index 40433a91f..312b8e845 100644 --- a/ext/node/polyfills/process.ts +++ b/ext/node/polyfills/process.ts @@ -5,10 +5,7 @@ // deno-lint-ignore-file prefer-primordials import { core, internals } from "ext:core/mod.js"; -import { op_geteuid, op_process_abort } from "ext:core/ops"; -const { - op_set_exit_code, -} = core.ensureFastOps(true); +import { op_geteuid, op_process_abort, op_set_exit_code } from "ext:core/ops"; import { notImplemented, warnNotImplemented } from "ext:deno_node/_utils.ts"; import { EventEmitter } from "node:events"; diff --git a/ext/node/polyfills/tty.js b/ext/node/polyfills/tty.js index eae1db2d9..b2260a47e 100644 --- a/ext/node/polyfills/tty.js +++ b/ext/node/polyfills/tty.js @@ -1,12 +1,10 @@ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. -import { core, primordials } from "ext:core/mod.js"; +import { primordials } from "ext:core/mod.js"; const { Error, } = primordials; -const { - op_is_terminal, -} = core.ensureFastOps(true); +import { op_is_terminal } from "ext:core/ops"; import { ERR_INVALID_FD } from "ext:deno_node/internal/errors.ts"; import { LibuvStreamWrap } from "ext:deno_node/internal_binding/stream_wrap.ts"; diff --git a/ext/node/polyfills/worker_threads.ts b/ext/node/polyfills/worker_threads.ts index 4092cac51..785bf021d 100644 --- a/ext/node/polyfills/worker_threads.ts +++ b/ext/node/polyfills/worker_threads.ts @@ -5,9 +5,7 @@ // deno-lint-ignore-file prefer-primordials import { core, internals } from "ext:core/mod.js"; -const { - op_require_read_closest_package_json, -} = core.ensureFastOps(true); +import { op_require_read_closest_package_json } from "ext:core/ops"; import { isAbsolute, resolve } from "node:path"; import { notImplemented } from "ext:deno_node/_utils.ts"; |