Skip to main content
Home

latest
Works with
This package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers
This package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
This package works with Bun
This package works with Browsers
JSR Score100%
Publisheda year ago (0.0.7)

A collection of utility functions regarding to time

function randomSleep
randomSleep(range: Range): Promise<void>

Pauses execution for a random duration within the specified range.

Examples

Example 1

for (item in downloadList) {
  await download(item);
  await randomSleep(new Range(1000, 5000));
}

Parameters

range: Range
  • An object that provides a method to get a random value within the range in milliseconds.

Return Type

Promise<void>

A promise that resolves after the random sleep duration.

Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

deno add jsr:@iharuya/time

Import symbol

import { randomSleep } from "@iharuya/time";
or

Import directly with a jsr specifier

import { randomSleep } from "jsr:@iharuya/time";

Add Package

pnpm i jsr:@iharuya/time
or (using pnpm 10.8 or older)
pnpm dlx jsr add @iharuya/time

Import symbol

import { randomSleep } from "@iharuya/time";

Add Package

yarn add jsr:@iharuya/time
or (using Yarn 4.8 or older)
yarn dlx jsr add @iharuya/time

Import symbol

import { randomSleep } from "@iharuya/time";

Add Package

vlt install jsr:@iharuya/time

Import symbol

import { randomSleep } from "@iharuya/time";

Add Package

npx jsr add @iharuya/time

Import symbol

import { randomSleep } from "@iharuya/time";

Add Package

bunx jsr add @iharuya/time

Import symbol

import { randomSleep } from "@iharuya/time";