Skip to content

Commit

Permalink
Updated docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
s1hofmann committed Jan 17, 2023
1 parent 7cecfc3 commit 651c61f
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 3 deletions.
34 changes: 32 additions & 2 deletions lib/query.class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,52 @@ type Query =

export type TextQuery = Extract<Query, { type: "text" }>;

export type WordQuery = Extract<TextQuery, { by: { word: string | RegExp } }>;
export type LineQuery = Extract<TextQuery, { by: { line: string | RegExp } }>;
/**
* A word query is a text query that searches for a single word on screen.
* It will be processed by an {@link TextFinderInterface} instance.
*/
export type WordQuery = Extract<TextQuery, { by: { word: string } }>;

/**
* A word query is a text query that searches for a single text line on screen.
* It will be processed by an {@link TextFinderInterface} instance.
*/
export type LineQuery = Extract<TextQuery, { by: { line: string } }>;

/**
* A window query is a query that searches for a window on screen.
* It will be processed by an {@link WindowFinderInterface} instance.
*/
export type WindowQuery = Extract<Query, { type: "window" }>;

/**
* Type guard for {@link WordQuery}
* @param possibleQuery A possible word query
*/
export const isWordQuery = (possibleQuery: any): possibleQuery is WordQuery => {
return possibleQuery?.type === "text" && possibleQuery?.by?.word != null;
};

/**
* Type guard for {@link LineQuery}
* @param possibleQuery A possible line query
*/
export const isLineQuery = (possibleQuery: any): possibleQuery is LineQuery => {
return possibleQuery?.type === "text" && possibleQuery?.by?.line != null;
};

/**
* Type guard for {@link TextQuery}
* @param possibleQuery A possible line or word query
*/
export const isTextQuery = (possibleQuery: any): possibleQuery is TextQuery => {
return possibleQuery?.type === "text";
};

/**
* Type guard for {@link WindowQuery}
* @param possibleQuery A possible window query
*/
export const isWindowQuery = (
possibleQuery: any
): possibleQuery is WindowQuery => {
Expand Down
2 changes: 1 addition & 1 deletion lib/screen.class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ export class ScreenClass {
* @param searchInput Filename of the template image, relative to {@link ScreenClass.config.resourceDirectory}, or an {@link Image}
* @param timeoutMs Timeout in milliseconds after which {@link waitFor} fails
* @param updateInterval Update interval in milliseconds to retry search
* @param params {@link LocationParameters} which are used to fine tune search region and / or match confidence
* @param params {@link OptionalSearchParameters} which are used to fine tune search region and / or match confidence
*/
public async waitFor<PROVIDER_DATA_TYPE>(
searchInput: RegionResultFindInput | Promise<RegionResultFindInput>,
Expand Down

0 comments on commit 651c61f

Please sign in to comment.