Skip to content

Commit

Permalink
reduce queries
Browse files Browse the repository at this point in the history
  • Loading branch information
Tokoeka committed Jan 30, 2024
1 parent e5d3a7f commit ea2a8a3
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ function notesText(): string {
);
}

function parseAliases(): Map<string, string> {
const questLogAliases: RegExpExecArray[] = notesText()
function parseAliases(notes: string): Map<string, string> {
const questLogAliases: RegExpExecArray[] = notes
.split("\n")
.map((s) => /^keeping-tabs: ?([A-Za-z0-9\- ]+)=(.*)/g.exec(s))
.filter((r) => r !== null) as RegExpExecArray[];
Expand All @@ -76,8 +76,8 @@ function parseAliases(): Map<string, string> {
return new Map(values);
}

function parseCollections(): Map<string, Item[]> {
const questLogEntries = notesText()
function parseCollections(notes: string): Map<string, Item[]> {
const questLogEntries = notes
.split("\n")
.map((s) => /^keeping-tabs-collection: ?'([^']*)'=(.*)\s*/g.exec(s))
.filter((r) => r !== null && r.length > 1) as RegExpMatchArray[];
Expand All @@ -89,8 +89,8 @@ function parseCollections(): Map<string, Item[]> {
return new Map(values);
}

function parseCoinmasters(): Map<Item, [Coinmaster, Item]> {
const questLogEntries: RegExpExecArray[] = notesText()
function parseCoinmasters(notes: string): Map<Item, [Coinmaster, Item]> {
const questLogEntries: RegExpExecArray[] = notes
.split("\n")
.map((s) => /^keeping-tabs-coinmaster: ?([0-9]+)=([0-9]+)/g.exec(s))
.filter((r) => r !== null) as RegExpExecArray[];
Expand Down Expand Up @@ -120,9 +120,10 @@ export function parseNotes(): {
collections: Map<string, Item[]>;
coinmasters: Map<Item, [Coinmaster, Item]>;
} {
const notes = notesText();
return {
aliases: parseAliases(),
collections: parseCollections(),
coinmasters: parseCoinmasters(),
aliases: parseAliases(notes),
collections: parseCollections(notes),
coinmasters: parseCoinmasters(notes),
};
}

0 comments on commit ea2a8a3

Please sign in to comment.