diff options
-rw-r--r-- | ext/node/lib.rs | 9 | ||||
-rw-r--r-- | ext/node/polyfills/internal_binding/stream_wrap.ts | 4 | ||||
-rw-r--r-- | ext/node/polyfills/internal_binding/types.ts | 3 |
3 files changed, 14 insertions, 2 deletions
diff --git a/ext/node/lib.rs b/ext/node/lib.rs index f139f0c7b..6d496f001 100644 --- a/ext/node/lib.rs +++ b/ext/node/lib.rs @@ -9,7 +9,10 @@ use deno_core::error::AnyError; use deno_core::located_script_name; use deno_core::op; use deno_core::serde_json; +use deno_core::serde_v8; use deno_core::url::Url; +#[allow(unused_imports)] +use deno_core::v8; use deno_core::JsRuntime; use deno_core::ModuleSpecifier; use deno_fs::sync::MaybeSend; @@ -130,6 +133,11 @@ fn op_node_build_os() -> String { .to_string() } +#[op(fast)] +fn op_is_any_arraybuffer(value: serde_v8::Value) -> bool { + value.v8_value.is_array_buffer() || value.v8_value.is_shared_array_buffer() +} + deno_core::extension!(deno_node, deps = [ deno_io, deno_fs ], parameters = [P: NodePermissions], @@ -224,6 +232,7 @@ deno_core::extension!(deno_node, ops::zlib::brotli::op_brotli_decompress_stream_end, ops::http::op_node_http_request<P>, op_node_build_os, + op_is_any_arraybuffer, ops::require::op_require_init_paths, ops::require::op_require_node_module_paths<P>, ops::require::op_require_proxy_path, diff --git a/ext/node/polyfills/internal_binding/stream_wrap.ts b/ext/node/polyfills/internal_binding/stream_wrap.ts index 4d2c8c4d7..27870b20b 100644 --- a/ext/node/polyfills/internal_binding/stream_wrap.ts +++ b/ext/node/polyfills/internal_binding/stream_wrap.ts @@ -279,7 +279,7 @@ export class LibuvStreamWrap extends HandleWrap { /** Internal method for reading from the attached stream. */ async #read() { - let buf = new Uint8Array(SUGGESTED_SIZE); + let buf = BUF; let nread: number | null; try { @@ -375,3 +375,5 @@ export class LibuvStreamWrap extends HandleWrap { return; } } + +const BUF = new Uint8Array(SUGGESTED_SIZE); diff --git a/ext/node/polyfills/internal_binding/types.ts b/ext/node/polyfills/internal_binding/types.ts index 28cf395f8..fe697f194 100644 --- a/ext/node/polyfills/internal_binding/types.ts +++ b/ext/node/polyfills/internal_binding/types.ts @@ -25,6 +25,7 @@ // deno-lint-ignore-file prefer-primordials const { core } = globalThis.__bootstrap; +const { ops } = core; // https://tc39.es/ecma262/#sec-object.prototype.tostring const _toString = Object.prototype.toString; @@ -89,7 +90,7 @@ function isObjectLike( export function isAnyArrayBuffer( value: unknown, ): value is ArrayBuffer | SharedArrayBuffer { - return isArrayBuffer(value) || isSharedArrayBuffer(value); + return ops.op_is_any_arraybuffer(value); } export function isArgumentsObject(value: unknown): value is IArguments { |