/
githubmirror
/
deno
Обзор
Документация
Войти
/
githubmirror
/
deno
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
libs/core/examples/disable_ops.rs
29 строк
720 B
Bartek Iwańczuk
chore: merge deno_core repo into main repo (#32353)
27 фев 2026, 21:25
Не верифицирован
27 фев 2026, 21:25
ad52a9f
Код
Авторство
О чём код?
// Copyright 2018-2026 the Deno authors. MIT license. //! This example shows you how to define ops in Rust and then call them from //! JavaScript. use deno_core::Extension; use deno_core::JsRuntime; use deno_core::RuntimeOptions; fn main() { let my_ext = Extension { name: "my_ext", middleware_fn: Some(Box::new(|op| match op.name { "op_print" => op.disable(), _ => op, })), ..Default::default() }; // Initialize a runtime instance let mut runtime = JsRuntime::new(RuntimeOptions { extensions: vec![my_ext], ..Default::default() }); // Deno.core.print() will now be a NOP runtime .execute_script("<usage>", r#"Deno.core.print("I'm broken")"#) .unwrap(); }