summaryrefslogtreecommitdiff
path: root/runtime/ops/fs_events.rs
diff options
context:
space:
mode:
authorMatt Mastracci <matthew@mastracci.com>2023-03-17 12:22:15 -0600
committerGitHub <noreply@github.com>2023-03-17 18:22:15 +0000
commite55b448730160a6e4df9815a268d4049ac89deab (patch)
tree35d80fd60f2f1d1d06903caff256484a7d703d76 /runtime/ops/fs_events.rs
parent0bc6bf5d33b8198253954d7f04558270de45c925 (diff)
feat(core) deno_core::extension! macro to simplify extension registration (#18210)
This implements two macros to simplify extension registration and centralize a lot of the boilerplate as a base for future improvements: * `deno_core::ops!` registers a block of `#[op]`s, optionally with type parameters, useful for places where we share lists of ops * `deno_core::extension!` is used to register an extension, and creates two methods that can be used at runtime/snapshot generation time: `init_ops` and `init_ops_and_esm`. --------- Co-authored-by: Bartek IwaƄczuk <biwanczuk@gmail.com>
Diffstat (limited to 'runtime/ops/fs_events.rs')
-rw-r--r--runtime/ops/fs_events.rs10
1 files changed, 4 insertions, 6 deletions
diff --git a/runtime/ops/fs_events.rs b/runtime/ops/fs_events.rs
index e550d204c..05cc22152 100644
--- a/runtime/ops/fs_events.rs
+++ b/runtime/ops/fs_events.rs
@@ -13,7 +13,6 @@ use deno_core::ResourceId;
use deno_core::op;
-use deno_core::Extension;
use notify::event::Event as NotifyEvent;
use notify::Error as NotifyError;
use notify::EventKind;
@@ -29,11 +28,10 @@ use std::path::PathBuf;
use std::rc::Rc;
use tokio::sync::mpsc;
-pub fn init() -> Extension {
- Extension::builder("deno_fs_events")
- .ops(vec![op_fs_events_open::decl(), op_fs_events_poll::decl()])
- .build()
-}
+deno_core::extension!(
+ deno_fs_events,
+ ops = [op_fs_events_open, op_fs_events_poll]
+);
struct FsEventsResource {
#[allow(unused)]