UNPKG

obsidian-dev-utils

Version:

This is the collection of useful functions that you can use for your Obsidian plugin development

54 lines (53 loc) 1.29 kB
/** * @packageDocumentation * * Contains utility functions for looping in Obsidian. */ import type { Promisable } from 'type-fest'; /** * Options for the loop function. */ export interface LoopOptions<T> { /** * An optional abort signal to cancel the loop. */ abortSignal?: AbortSignal; /** * The function to build the notice message for each item. */ buildNoticeMessage(item: T, iterationStr: string): string; /** * The items to loop over. */ items: T[]; /** * The minimum timeout for the notice. */ noticeMinTimeoutInMilliseconds?: number; /** * The function to process each item. */ processItem(item: T): Promisable<void>; /** * The title of the progress bar. */ progressBarTitle?: string; /** * Whether to continue the loop on error. */ shouldContinueOnError?: boolean; /** * Whether to show a progress bar. */ shouldShowProgressBar?: boolean; /** * The threshold for the UI update. */ uiUpdateThresholdInMilliseconds?: number; } /** * Loops over a list of items and processes each item. * * @param options - The options for the loop. */ export declare function loop<T>(options: LoopOptions<T>): Promise<void>;