diff options
Diffstat (limited to 'ext/node/ops')
-rw-r--r-- | ext/node/ops/buffer.rs | 13 | ||||
-rw-r--r-- | ext/node/ops/mod.rs | 1 |
2 files changed, 14 insertions, 0 deletions
diff --git a/ext/node/ops/buffer.rs b/ext/node/ops/buffer.rs new file mode 100644 index 000000000..74a011ab8 --- /dev/null +++ b/ext/node/ops/buffer.rs @@ -0,0 +1,13 @@ +// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. + +use deno_core::op2; + +#[op2(fast)] +pub fn op_is_ascii(#[buffer] buf: &[u8]) -> bool { + buf.is_ascii() +} + +#[op2(fast)] +pub fn op_is_utf8(#[buffer] buf: &[u8]) -> bool { + std::str::from_utf8(buf).is_ok() +} diff --git a/ext/node/ops/mod.rs b/ext/node/ops/mod.rs index 6381530dd..ae703e3f3 100644 --- a/ext/node/ops/mod.rs +++ b/ext/node/ops/mod.rs @@ -1,5 +1,6 @@ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. +pub mod buffer; pub mod crypto; pub mod fs; pub mod http; |