-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathutils.d.ts
47 lines (39 loc) · 1.78 KB
/
utils.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import classNames from "classnames";
export interface Utils {
/** Finds a value, subobject, or array from a tree that matches a specific filter. This is a DFS. */
findInTree(
tree: any,
searchFilter: (node: any) => boolean,
options?: FindInTreeOptions,
): any;
/**
* Deep extends an object with a set of other objects.
* Objects later in the list of `extenders` have priority, that is to say if one sets a key to be a primitive,
* it will be overwritten with the next one with the same key.
* If it is an object, and the keys match, the object is extended.
* This happens recursively.
*/
extend(extendee: any, ...extenders: any[]): any;
/**
* Returns a function, that, as long as it continues to be invoked, will not be triggered.
* The function will be called after it stops being called for `delay` milliseconds.
*/
debounce<F extends (...args: any) => any>(executor: F, delay: number): F;
/** Takes a string of HTML and escapes it using the browser's own escaping mechanism. */
escapeHTML(html: string): string;
/**
* Builds a classname string from any number of arguments.
* This includes arrays and objects.
* When given an array all values from the array are added to the list.
* When given an object they keys are added as the classnames if the value is truthy.
*/
className: typeof classNames;
/** Gets a nested value (if it exists) of an object safely. */
getNestedValue(obj: Record<string, any>, keyPath: string): any;
/** Compares versions according to semantic versioning. */
semverCompare(currentVersion: string, newVersion: string): -1 | 0 | 1;
}
export interface FindInTreeOptions {
walkable?: string[] | null;
ignore?: string[];
}