insta-toc
Version:
Simultaneously generate, update, and maintain a table of contents for your notes in real time.
47 lines (42 loc) • 2.16 kB
TypeScript
declare global {
type Omitted<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
type StringRegex = `/${string}/`;
function assert<T>(value: T | null | undefined, message?: string): asserts value is NonNullable<T>;
function isNothing<T>(value: T): value is Extract<T, null | undefined>;
function sortRecord<T extends Record<string, any>>(
obj: T,
sortFn?: (a: [keyof T, T[keyof T]?], b: [keyof T, T[keyof T]?]) => number
): Record<string, T[keyof T]>;
function sortMap<K, V>(map: Map<K, V>, sortFn?: (a: [K, V], b: [K, V]) => number): Map<K, V>;
function isRecord<T extends Record<string, unknown>>(value: unknown): value is T;
function isMap<K = unknown, V = unknown>(value: unknown): value is Map<K, V>;
interface RegExpConstructor {
/**
* Escape special characters in a string for use in a regular expression pattern
* @param value The input string that may contain special characters that need to be escaped for use in a regular expression
* @returns A new string with special characters escaped, so that it can be safely used in a regular expression pattern without being interpreted as regex syntax
*/
escape(value: string): string;
/**
* Check if a string is a regex pattern
* @param str The input string to check for being a regex pattern, which is determined by whether it starts and ends with a forward slash '/'
* @returns A boolean value indicating whether the input string is a regex pattern (true) or not (false), based on the presence of starting and ending forward slashes
*/
isRegexPattern(str: string): str is StringRegex;
}
}
declare module "obsidian" {
interface MarkdownView {
getState(): {
/** The current active file path. */
file: `${string}.md`;
/** The current mode. */
mode: "preview" | "source";
/** Whether the view is in source mode. */
source: boolean;
/** Whether the file contains backlinks. */
backlinks: boolean;
};
}
}
export {};