Skip to content

Commit

Permalink
docs: improve comments for typedoc
Browse files Browse the repository at this point in the history
  • Loading branch information
andrepolischuk committed Aug 15, 2024
1 parent 8df5e85 commit bb23801
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 9 deletions.
9 changes: 5 additions & 4 deletions packages/async/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
const RETRIES_LEFT = 3
const INTERVAL = 500

export type PromiseFactory<T> = (...args: any[]) => Promise<T>
/** Retryable function */
export type RetryableFunction<T> = (...args: any[]) => Promise<T>

/** Retry options */
export interface RetryOptions {
Expand All @@ -19,15 +20,15 @@ export interface RetryOptions {

/** Retry function call */
export function retry<T>(
factory: PromiseFactory<T>,
retryableFunction: RetryableFunction<T>,
options: RetryOptions = {}
): PromiseFactory<T> {
): RetryableFunction<T> {
let {retries = RETRIES_LEFT} = options
const {timeout = INTERVAL, shouldRetry = () => true, signal} = options

async function call(...args: any[]): Promise<T> {
try {
return await factory(...args)
return await retryableFunction(...args)
} catch (error: any) {
if (--retries < 1 || !shouldRetry(error)) {
throw error
Expand Down
3 changes: 2 additions & 1 deletion packages/crypto/crypto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ export function isSupported() {
return !!crypto
}

type TypedArray =
/** Typed array */
export type TypedArray =
| Int8Array
| Uint8Array
| Uint8ClampedArray
Expand Down
2 changes: 1 addition & 1 deletion packages/crypto/index.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
1 change: 1 addition & 0 deletions packages/errors/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
1 change: 1 addition & 0 deletions packages/splits/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
9 changes: 6 additions & 3 deletions packages/url/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
/* eslint-disable import/no-unused-modules */

export type ParsedQuery<T = string> = Record<string, T | T[] | null | undefined>

/** Query object */
export type Query = Record<string, any>

interface UrlObject {
/** Parsed query object */
export type ParsedQuery<T = string> = Record<string, T | T[] | null | undefined>

/** URL object */
export interface UrlObject {
protocol?: string | null
host?: string | null
pathname?: string | null
Expand Down

0 comments on commit bb23801

Please sign in to comment.