deno.land / std@0.224.0 / async / _util.ts

نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.// This module is browser compatible.
// This `reason` comes from `AbortSignal` thus must be `any`.// deno-lint-ignore no-explicit-anyexport function createAbortError(reason?: any): DOMException { return new DOMException( reason ? `Aborted: ${reason}` : "Aborted", "AbortError", );}
export function exponentialBackoffWithJitter( cap: number, base: number, attempt: number, multiplier: number, jitter: number,) { const exp = Math.min(cap, base * multiplier ** attempt); return (1 - jitter * Math.random()) * exp;}
std

Version Info

Tagged at
3 weeks ago