1
0
mirror of https://github.com/robonen/tools.git synced 2026-03-20 10:54:44 +00:00

ci: add registry-url

This commit is contained in:
2025-05-09 13:38:29 +07:00
parent 09e72d904c
commit 88f6cec9b2
4 changed files with 102 additions and 4 deletions

View File

@@ -0,0 +1,38 @@
export interface RetryOptions {
times?: number;
delay?: number;
backoff: (options: RetryOptions & { count: number }) => number;
}
/**
* @name retry
* @category Async
* @description Retries a function a specified number of times with a delay between each retry
*
* @param {Promise<unknown>} fn - The function to retry
* @param {RetryOptions} options - The options for the retry
* @returns {Promise<unknown>} - The result of the function
*
* @example
* const result = await retry(() => {
* return fetch('https://jsonplaceholder.typicode.com/todos/1')
* .then(response => response.json())
* });
*
* @example
* const result = await retry(() => {
* return fetch('https://jsonplaceholder.typicode.com/todos/1')
* .then(response => response.json())
* }, { times: 3, delay: 1000 });
*
*/
export async function retry<Return>(
fn: () => Promise<Return>,
options: RetryOptions
) {
const {
times = 3,
} = options;
let count = 0;
}

View File

@@ -2,9 +2,9 @@
* @name timestamp
* @category Utils
* @description Returns the current timestamp
*
*
* @returns {number} The current timestamp
*
*
* @since 0.0.2
*/
export const timestamp = () => Date.now();
@@ -13,9 +13,9 @@ export const timestamp = () => Date.now();
* @name noop
* @category Utils
* @description A function that does nothing
*
*
* @returns {void} Nothing
*
*
* @since 0.0.2
*/
export const noop = () => {};