From bb2380118f3e1389b9025dc781e8b6e50397e581 Mon Sep 17 00:00:00 2001 From: Andrey Polischuk Date: Thu, 15 Aug 2024 17:12:08 +0300 Subject: [PATCH] docs: improve comments for typedoc --- packages/async/index.ts | 9 +++++---- packages/crypto/crypto.ts | 3 ++- packages/crypto/index.ts | 2 +- packages/errors/index.ts | 1 + packages/splits/index.ts | 1 + packages/url/index.ts | 9 ++++++--- 6 files changed, 16 insertions(+), 9 deletions(-) diff --git a/packages/async/index.ts b/packages/async/index.ts index 942aae1..85ddb15 100644 --- a/packages/async/index.ts +++ b/packages/async/index.ts @@ -3,7 +3,8 @@ const RETRIES_LEFT = 3 const INTERVAL = 500 -export type PromiseFactory = (...args: any[]) => Promise +/** Retryable function */ +export type RetryableFunction = (...args: any[]) => Promise /** Retry options */ export interface RetryOptions { @@ -19,15 +20,15 @@ export interface RetryOptions { /** Retry function call */ export function retry( - factory: PromiseFactory, + retryableFunction: RetryableFunction, options: RetryOptions = {} -): PromiseFactory { +): RetryableFunction { let {retries = RETRIES_LEFT} = options const {timeout = INTERVAL, shouldRetry = () => true, signal} = options async function call(...args: any[]): Promise { try { - return await factory(...args) + return await retryableFunction(...args) } catch (error: any) { if (--retries < 1 || !shouldRetry(error)) { throw error diff --git a/packages/crypto/crypto.ts b/packages/crypto/crypto.ts index c49c607..42a124c 100644 --- a/packages/crypto/crypto.ts +++ b/packages/crypto/crypto.ts @@ -11,7 +11,8 @@ export function isSupported() { return !!crypto } -type TypedArray = +/** Typed array */ +export type TypedArray = | Int8Array | Uint8Array | Uint8ClampedArray diff --git a/packages/crypto/index.ts b/packages/crypto/index.ts index 4b48d19..213ee49 100644 --- a/packages/crypto/index.ts +++ b/packages/crypto/index.ts @@ -1,5 +1,5 @@ /* eslint-disable import/no-unused-modules */ -export {getRandomValues, isSupported, subtle} from './crypto' +export {getRandomValues, isSupported, subtle, type TypedArray} from './crypto' export { bufferFromString, stringFromBuffer, diff --git a/packages/errors/index.ts b/packages/errors/index.ts index 4875d28..442615c 100644 --- a/packages/errors/index.ts +++ b/packages/errors/index.ts @@ -28,6 +28,7 @@ export class GenericError extends Error { code: GenericErrorInput['code'] details?: GenericErrorInput['details'] + /** Generic error constructor */ constructor(message: string, input?: GenericErrorInput) { super() this.name = 'GenericError' diff --git a/packages/splits/index.ts b/packages/splits/index.ts index 8ae8b9d..107e458 100644 --- a/packages/splits/index.ts +++ b/packages/splits/index.ts @@ -74,6 +74,7 @@ export class Splits { private tests: SplitTest[] private options: SplitsOptions + /** Splits constructor */ public constructor(tests: SplitTest[], options: SplitsOptions = {}) { if (!Array.isArray(tests) || !tests.length) { throw new Error('expected `settings.tests` is not empty array') diff --git a/packages/url/index.ts b/packages/url/index.ts index 6bea03d..f47b557 100644 --- a/packages/url/index.ts +++ b/packages/url/index.ts @@ -1,10 +1,13 @@ /* eslint-disable import/no-unused-modules */ -export type ParsedQuery = Record - +/** Query object */ export type Query = Record -interface UrlObject { +/** Parsed query object */ +export type ParsedQuery = Record + +/** URL object */ +export interface UrlObject { protocol?: string | null host?: string | null pathname?: string | null