Skip to content

Commit

Permalink
Merge pull request #28 from grafana/timersUpdate
Browse files Browse the repository at this point in the history
Stabalize k6/experimental/timers
  • Loading branch information
oleiade committed Mar 18, 2024
2 parents 215e1ba + c064419 commit ade6745
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 4 deletions.
6 changes: 3 additions & 3 deletions types/k6/experimental/timers.d.ts
Expand Up @@ -3,7 +3,7 @@
*/

/**
* Set a timer which execution a function once the timer expires.
* Set a timer that executes a function once the timer expires.
*
* @param functionRef - The function to be executed.
* @param delay - The delay in milliseconds.
Expand All @@ -13,7 +13,7 @@
export function setTimeout(functionRef: (...args: any[]) => void, delay: number, ...args: any[]): TimeoutID;

/**
* Cancels a timeout previously set with setTimeout().
* Cancels a timer previously set with setTimeout().
*
* @param timeoutID - The timer id to be cancelled.
*/
Expand All @@ -30,7 +30,7 @@ export function clearTimeout(timeoutID: TimeoutID): void;
export function setInterval(functionRef: (...args: any[]) => void, delay: number, ...args: any[]): IntervalID;

/**
* Cancels a interval previously set with setInterval().
* Cancels an interval previously set with setInterval().
*
* @param intervalID - The interval id to be cancelled.
*/
Expand Down
1 change: 1 addition & 0 deletions types/k6/index.d.ts
Expand Up @@ -36,6 +36,7 @@ import "./experimental/tracing";
import "./experimental/webcrypto";
import "./experimental/websockets";
import "./experimental/grpc";
import "./timers";
import "./ws";
import "./net/grpc";

Expand Down
2 changes: 1 addition & 1 deletion types/k6/test/timers.ts
@@ -1,4 +1,4 @@
import { clearInterval, clearTimeout, setInterval, setTimeout } from "k6/experimental/timers";
import { clearInterval, clearTimeout, setInterval, setTimeout } from "k6/timers";

// setTimeout

Expand Down
47 changes: 47 additions & 0 deletions types/k6/timers.d.ts
@@ -0,0 +1,47 @@
/**
* This module provides setInterval, setTimeout and co.
*/

/**
* Set a timer that executes a function once the timer expires.
*
* @param functionRef - The function to be executed.
* @param delay - The delay in milliseconds.
* @param args - The arguments to be passed to the function.
* @returns The timer id.
*/
export function setTimeout(functionRef: (...args: any[]) => void, delay: number, ...args: any[]): TimeoutID;

/**
* Cancels a timer previously set with setTimeout().
*
* @param timeoutID - The timer id to be cancelled.
*/
export function clearTimeout(timeoutID: TimeoutID): void;

/**
* Repeatedly execute a function, with a fixed time delay between each call.
*
* @param functionRef - The function to be executed.
* @param delay - The delay in milliseconds.
* @param args - The arguments to be passed to the function.
* @returns The interval id.
*/
export function setInterval(functionRef: (...args: any[]) => void, delay: number, ...args: any[]): IntervalID;

/**
* Cancels an interval previously set with setInterval().
*
* @param intervalID - The interval id to be cancelled.
*/
export function clearInterval(intervalID: IntervalID): void;

/**
* Type alias for a timer id.
*/
export type TimeoutID = number;

/**
* Type alias for a interval id.
*/
export type IntervalID = number;

0 comments on commit ade6745

Please sign in to comment.