Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stabalize k6/experimental/timers #28

Merged
merged 3 commits into from Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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;