-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[load-time-optimization] improve expand-moves
We did not use all-of “fcs-validate” so capitalize-cards.ts was extracted. Also see https://www.shlomifish.org/meta/FAQ/site_loads_quickly.xhtml
- Loading branch information
Showing
5 changed files
with
54 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
export class BoardTextLine { | ||
private newline: string; | ||
private comment: string; | ||
private prefix: string; | ||
private content: string; | ||
constructor(public line: string) { | ||
const that = this; | ||
const m1 = line.match(/^([^\n\r]*)([\n\r]*)$/); | ||
that.newline = m1[2]; | ||
let l = m1[1]; | ||
if (m1[1].match(/#/)) { | ||
const m2 = m1[1].match(/^(.*?)(#.*)/); | ||
that.comment = m2[2]; | ||
l = m2[1]; | ||
} else { | ||
that.comment = ""; | ||
} | ||
if (l.match(/:/)) { | ||
const m3 = l.match(/^([^:]*:)(.*)/); | ||
that.prefix = m3[1]; | ||
that.content = m3[2]; | ||
} else { | ||
that.prefix = ""; | ||
that.content = l; | ||
} | ||
return; | ||
} | ||
public getContent(): string { | ||
return this.content; | ||
} | ||
public capitalize(): string { | ||
const that = this; | ||
const ret = | ||
that.prefix + | ||
that.getContent().toUpperCase() + | ||
that.comment + | ||
that.newline; | ||
return ret; | ||
} | ||
} | ||
|
||
export function capitalize_cards(board: string): string { | ||
return board | ||
.match(/[^\n]*\n?/g) | ||
.map((l) => { | ||
return new BoardTextLine(l).capitalize(); | ||
}) | ||
.join(""); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters