summaryrefslogtreecommitdiff
path: root/cli/js/ops/timers.ts
blob: 1a7081df03581d1e217987f52fd427398694a003 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
import { sendSync, sendAsync } from "./dispatch_json.ts";

export function stopGlobalTimer(): void {
  sendSync("op_global_timer_stop");
}

export async function startGlobalTimer(timeout: number): Promise<void> {
  await sendAsync("op_global_timer", { timeout });
}

interface NowResponse {
  seconds: number;
  subsecNanos: number;
}

export function now(): NowResponse {
  return sendSync("op_now");
}