Skip to content

Commit

Permalink
chore: Format files.
Browse files Browse the repository at this point in the history
  • Loading branch information
vxern committed Mar 2, 2024
1 parent f73ee10 commit 945e120
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 24 deletions.
3 changes: 3 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
},
"suspicious": {
"noEmptyInterface": "off"
},
"complexity": {
"noExcessiveCognitiveComplexity": "off"
}
}
},
Expand Down
2 changes: 1 addition & 1 deletion src/constants/copyright.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @remarks
* This is a list of dictionary identifiers that are under copyright, and cannot be queried without explicit permission.
*
*
* `dexonline-scraper` filters entries out from them by default, however this can be overriden in the case of
* having obtained explicit permission for a given dictionary.
*/
Expand Down
10 changes: 5 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ const defaultSearchOptions = Object.freeze({
excludeCopyrighted: true,
flags: DictionaryFlags.None,
} as const satisfies ParserOptions);
const defaultSearchOptionsWithWord = Object.freeze({ ...defaultSearchOptions, word: "" } as const satisfies SearchOptionsWithWord);
const defaultSearchOptionsWithWord = Object.freeze({
...defaultSearchOptions,
word: "",
} as const satisfies SearchOptionsWithWord);

export interface Results {
readonly synthesis: Synthesis.Lemma[];
Expand Down Expand Up @@ -54,10 +57,7 @@ export async function get(
* @param options - Options for searching.
* @returns A {@link Results} object or {@link undefined} if unable to parse.
*/
export function parse(
contents: string,
options: SearchOptionsWithWord<true> = defaultSearchOptionsWithWord,
): Results {
export function parse(contents: string, options: SearchOptionsWithWord<true> = defaultSearchOptionsWithWord): Results {
const $ = cheerio.load(contents);

const optionsFilled: SearchOptionsWithWord<false> = {
Expand Down
20 changes: 10 additions & 10 deletions src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,16 @@ export interface ParserOptions {
readonly flags: DictionaryFlags;
}

export type SearchOptionsWithWord<IsPartial extends boolean = false> = Readonly<(IsPartial extends true
? Partial<ParserOptions>
: ParserOptions) &
(
| { mode: "lax"; word?: string; }
| {
mode: "strict";
word: string;
}
)>;
export type SearchOptionsWithWord<IsPartial extends boolean = false> = Readonly<
(IsPartial extends true ? Partial<ParserOptions> : ParserOptions) &
(
| { mode: "lax"; word?: string }
| {
mode: "strict";
word: string;
}
)
>;

/**
* Bit-based flags for configuring the dictionary and the results sent back by it.
Expand Down
16 changes: 8 additions & 8 deletions src/tabs/inflection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,24 @@ export interface InflectionModel extends Heading, Table {}

/** Represents the heading of a Dexonline inflection model. */
interface Heading {
/** The tags for a given inflection model. */
/** The tags for a given inflection model. */
readonly tags: string[];
/** The index of the inflection model as shown on the webpage. */
/** The index of the inflection model as shown on the webpage. */
readonly index: number;
/** The lemma this inflection model applies to */
/** The lemma this inflection model applies to */
readonly lemma: string;
}

/** Represents the body (table) of a Dexonline inflection model. */
interface Table {
/** The HTML table represented as a 2D array of rows and columns. */
/** The HTML table represented as a 2D array of rows and columns. */
readonly table: string[][];
}

/**
* Given a {@link $|Cheerio document handle} and additional {@link options} for scraping entries, scrapes the
* inflection models on the page.
*
*
* @param $ - A Cheerio document handle for the webpage.
* @param options - Options for the scraper.
* @returns An array of the scraped {@link InflectionModel}s.
Expand Down Expand Up @@ -56,7 +56,7 @@ export function scrape($: CheerioAPI, options: SearchOptionsWithWord): Inflectio

/**
* Given a {@link $|Cheerio document handle} for the inflection model on the webpage, scrapes its heading.
*
*
* @param $ - A Cheerio document handle for the webpage.
* @param $heading - A Cheerio document handle for the heading of the inflection model.
* @returns The scraped inflection model {@link Heading}.
Expand Down Expand Up @@ -93,7 +93,7 @@ function scrapeHeading($: CheerioAPI, $heading: Cheerio<Element>): Heading {

/**
* Given a {@link $|Cheerio document handle} for the inflection model on the webpage, scrapes its table.
*
*
* @param $ - A Cheerio document handle for the webpage.
* @param $heading - A Cheerio document handle for the table of the inflection model.
* @returns The scraped inflection model {@link Table}.
Expand Down Expand Up @@ -183,7 +183,7 @@ function scrapeTable($: CheerioAPI, body: Cheerio<Element>): Table {
/**
* Given a {@link $|Cheerio document handle} for a cell inside the table for an inflection model, gets the
* contents of the cell.
*
*
* @param $ - A Cheerio document handle for the webpage.
* @param $heading - A Cheerio document handle for the cell element.
* @returns The scraped contents of the cell.
Expand Down

0 comments on commit 945e120

Please sign in to comment.