diff options
author | Aaron O'Mullan <aaron.omullan@gmail.com> | 2021-04-29 00:16:45 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-28 18:16:45 -0400 |
commit | e89295b176b4f494d19b547b6b4d7c98d0cf1da1 (patch) | |
tree | ae2f043d8a883b6f6f754c057b8dfe678b3c7944 /op_crates/timers/lib.rs | |
parent | e63c53315450ed305752566f4c3ad2bb76c8b8a3 (diff) |
refactor(extensions): reintroduce builder (#10412)
Diffstat (limited to 'op_crates/timers/lib.rs')
-rw-r--r-- | op_crates/timers/lib.rs | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/op_crates/timers/lib.rs b/op_crates/timers/lib.rs index 6359b20f0..62f5953fa 100644 --- a/op_crates/timers/lib.rs +++ b/op_crates/timers/lib.rs @@ -13,6 +13,7 @@ use deno_core::futures; use deno_core::futures::channel::oneshot; use deno_core::futures::FutureExt; use deno_core::futures::TryFutureExt; +use deno_core::include_js_files; use deno_core::op_async; use deno_core::op_sync; use deno_core::Extension; @@ -41,24 +42,24 @@ impl TimersPermission for NoTimersPermission { } pub fn init<P: TimersPermission + 'static>() -> Extension { - Extension::with_ops( - vec![( - "deno:op_crates/timers/01_timers.js", - include_str!("01_timers.js"), - )], - vec![ + Extension::builder() + .js(include_js_files!( + prefix "deno:op_crates/timers", + "01_timers.js", + )) + .ops(vec![ ("op_global_timer_stop", op_sync(op_global_timer_stop)), ("op_global_timer_start", op_sync(op_global_timer_start)), ("op_global_timer", op_async(op_global_timer)), ("op_now", op_sync(op_now::<P>)), ("op_sleep_sync", op_sync(op_sleep_sync::<P>)), - ], - Some(Box::new(|state| { + ]) + .state(|state| { state.put(GlobalTimer::default()); state.put(StartTime::now()); Ok(()) - })), - ) + }) + .build() } pub type StartTime = Instant; |