From 515a34b4de222e35c7ade1b92614d746e73d4c2e Mon Sep 17 00:00:00 2001 From: Kenta Moriuchi Date: Thu, 11 Jan 2024 07:37:25 +0900 Subject: refactor: use `core.ensureFastOps()` (#21888) --- ext/node/polyfills/internal/crypto/_randomFill.mjs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'ext/node/polyfills/internal/crypto/_randomFill.mjs') diff --git a/ext/node/polyfills/internal/crypto/_randomFill.mjs b/ext/node/polyfills/internal/crypto/_randomFill.mjs index 7f66cfb4b..cb61e27ef 100644 --- a/ext/node/polyfills/internal/crypto/_randomFill.mjs +++ b/ext/node/polyfills/internal/crypto/_randomFill.mjs @@ -3,17 +3,18 @@ // TODO(petamoriken): enable prefer-primordials for node polyfills // deno-lint-ignore-file prefer-primordials +import { core } from "ext:core/mod.js"; +const { + op_node_generate_secret, + op_node_generate_secret_async, +} = core.ensureFastOps(true); + import { MAX_SIZE as kMaxUint32, } from "ext:deno_node/internal/crypto/_randomBytes.ts"; import { Buffer } from "node:buffer"; import { isAnyArrayBuffer, isArrayBufferView } from "node:util/types"; import { ERR_INVALID_ARG_TYPE } from "ext:deno_node/internal/errors.ts"; -const { core } = globalThis.__bootstrap; -const { ops } = core; -const { - op_node_generate_secret_async, -} = core.ensureFastOps(); const kBufferMaxLength = 0x7fffffff; @@ -87,7 +88,7 @@ export function randomFillSync(buf, offset = 0, size) { } const bytes = new Uint8Array(buf.buffer ? buf.buffer : buf, offset, size); - ops.op_node_generate_secret(bytes); + op_node_generate_secret(bytes); return buf; } -- cgit v1.2.3