Skip to content

Commit e0b1932

Browse files
Miodecmshareef-git
authored andcommitted
chore: rename functions (to make upcoming pr diff easier to parse)
1 parent c711625 commit e0b1932

15 files changed

Lines changed: 46 additions & 42 deletions

File tree

frontend/src/ts/elements/caret.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ export class Caret {
287287
const word = wordsCache.qs(
288288
`.word[data-wordindex="${options.wordIndex}"]`,
289289
);
290-
const wordText = TestWords.words.get(options.wordIndex) ?? "";
290+
const wordText = TestWords.words.getText(options.wordIndex) ?? "";
291291
const wordLength = Array.from(wordText).length;
292292

293293
// caret can be either on the left side of the target letter or the right

frontend/src/ts/input/handlers/before-delete.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export function onBeforeDelete(event: InputEvent): void {
4343
const confidence = Config.confidenceMode;
4444
const previousWordCorrect =
4545
(TestInput.input.get(TestState.activeWordIndex - 1) ?? "") ===
46-
TestWords.words.get(TestState.activeWordIndex - 1);
46+
TestWords.words.getText(TestState.activeWordIndex - 1);
4747

4848
if (confidence === "on" && inputIsEmpty && !previousWordCorrect) {
4949
event.preventDefault();

frontend/src/ts/input/handlers/before-insert-text.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export function onBeforeInsertText(data: string): boolean {
3434
const shouldInsertSpaceAsCharacter = shouldInsertSpaceCharacter({
3535
data,
3636
inputValue,
37-
targetWord: TestWords.words.getCurrent(),
37+
targetWord: TestWords.words.getCurrentText(),
3838
});
3939

4040
//prevent space from being inserted if input is empty
@@ -60,7 +60,7 @@ export function onBeforeInsertText(data: string): boolean {
6060

6161
// block input if the word is too long
6262
const inputLimit =
63-
Config.mode === "zen" ? 30 : TestWords.words.getCurrent().length + 20;
63+
Config.mode === "zen" ? 30 : TestWords.words.getCurrentText().length + 20;
6464
const overLimit = TestInput.input.current.length >= inputLimit;
6565
if (overLimit && (shouldInsertSpaceAsCharacter === true || !dataIsSpace)) {
6666
console.error("Hitting word limit");
@@ -71,7 +71,7 @@ export function onBeforeInsertText(data: string): boolean {
7171
// this will not work for the first word of each line, but that has a low chance of happening
7272
const dataIsNotFalsy = data !== null && data !== "";
7373
const inputIsLongerThanOrEqualToWord =
74-
TestInput.input.current.length >= TestWords.words.getCurrent().length;
74+
TestInput.input.current.length >= TestWords.words.getCurrentText().length;
7575

7676
if (
7777
!SlowTimer.get() && // don't do this check if slow timer is active

frontend/src/ts/input/handlers/delete.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export function onDelete(inputType: DeleteInputType): void {
2020

2121
const beforeDeleteOnlyTabs = /^\t*$/.test(inputBeforeDelete);
2222
const allTabsCorrect = TestWords.words
23-
.getCurrent()
23+
.getCurrentText()
2424
.startsWith(TestInput.input.current);
2525

2626
//special check for code languages

frontend/src/ts/input/handlers/insert-text.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ export async function onInsertText(options: OnInsertTextParams): Promise<void> {
8585
const charOverride = charOverrides.get(options.data);
8686
if (
8787
charOverride !== undefined &&
88-
TestWords.words.getCurrent()[TestInput.input.current.length] !==
88+
TestWords.words.getCurrentText()[TestInput.input.current.length] !==
8989
options.data
9090
) {
9191
// replace the data with the override
@@ -101,7 +101,7 @@ export async function onInsertText(options: OnInsertTextParams): Promise<void> {
101101

102102
// input and target word
103103
const testInput = TestInput.input.current;
104-
const currentWord = TestWords.words.getCurrent();
104+
const currentWord = TestWords.words.getCurrentText();
105105

106106
// if the character is visually equal, replace it with the target character
107107
// this ensures all future equivalence checks work correctly
@@ -151,7 +151,7 @@ export async function onInsertText(options: OnInsertTextParams): Promise<void> {
151151
// word navigation check
152152
const noSpaceForce =
153153
isFunboxActiveWithProperty("nospace") &&
154-
(testInput + data).length === TestWords.words.getCurrent().length;
154+
(testInput + data).length === TestWords.words.getCurrentText().length;
155155
const shouldGoToNextWord =
156156
((charIsSpace || charIsNewline) && !shouldInsertSpace) || noSpaceForce;
157157

@@ -169,7 +169,7 @@ export async function onInsertText(options: OnInsertTextParams): Promise<void> {
169169
TestInput.pushKeypressWord(wordIndex);
170170
if (!correct) {
171171
TestInput.incrementKeypressErrors();
172-
TestInput.pushMissedWord(TestWords.words.getCurrent());
172+
TestInput.pushMissedWord(TestWords.words.getCurrentText());
173173
}
174174
if (Config.keymapMode === "react") {
175175
flash(data, correct);
@@ -236,7 +236,7 @@ export async function onInsertText(options: OnInsertTextParams): Promise<void> {
236236
*/
237237

238238
//this COULD be the next word because we are awaiting goToNextWord
239-
const nextWord = TestWords.words.getCurrent();
239+
const nextWord = TestWords.words.getCurrentText();
240240
const doesNextWordHaveTab = /^\t+/.test(nextWord);
241241
const isCurrentCharTab = nextWord[TestInput.input.current.length] === "\t";
242242

frontend/src/ts/input/helpers/word-navigation.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ export async function goToNextWord({
6060
TestInput.pushBurstToHistory(burst);
6161
ret.lastBurst = burst;
6262

63-
PaceCaret.handleSpace(correctInsert, TestWords.words.getCurrent());
63+
PaceCaret.handleSpace(correctInsert, TestWords.words.getCurrentText());
6464

65-
Funbox.toggleScript(TestWords.words.get(TestState.activeWordIndex + 1));
65+
Funbox.toggleScript(TestWords.words.getText(TestState.activeWordIndex + 1));
6666

6767
TestInput.input.pushHistory();
6868
TestInput.corrected.pushHistory();
@@ -111,7 +111,7 @@ export function goToPreviousWord(
111111
TestState.decreaseActiveWordIndex();
112112
TestInput.corrected.popHistory();
113113

114-
Funbox.toggleScript(TestWords.words.get(TestState.activeWordIndex));
114+
Funbox.toggleScript(TestWords.words.getText(TestState.activeWordIndex));
115115

116116
const nospaceEnabled = isFunboxActiveWithProperty("nospace");
117117

frontend/src/ts/input/listeners/input.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ inputEl.addEventListener("input", async (event) => {
125125
const inputPlusComposition =
126126
TestInput.input.current + (CompositionState.getData() ?? "");
127127
const inputPlusCompositionIsCorrect =
128-
TestWords.words.getCurrent() === inputPlusComposition;
128+
TestWords.words.getCurrentText() === inputPlusComposition;
129129

130130
// composition quick end
131131
// if the user typed the entire word correctly but is still in composition

frontend/src/ts/test/funbox/funbox-functions.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export type FunboxFunctions = {
5454
async function readAheadHandleKeydown(event: KeyboardEvent): Promise<void> {
5555
const inputCurrentChar = (TestInput.input.current ?? "").slice(-1);
5656
const wordCurrentChar = TestWords.words
57-
.getCurrent()
57+
.getCurrentText()
5858
.slice(TestInput.input.current.length - 1, TestInput.input.current.length);
5959
const isCorrect = inputCurrentChar === wordCurrentChar;
6060

@@ -63,7 +63,7 @@ async function readAheadHandleKeydown(event: KeyboardEvent): Promise<void> {
6363
!isCorrect &&
6464
(TestInput.input.current !== "" ||
6565
TestInput.input.getHistory(TestState.activeWordIndex - 1) !==
66-
TestWords.words.get(TestState.activeWordIndex - 1) ||
66+
TestWords.words.getText(TestState.activeWordIndex - 1) ||
6767
Config.freedomMode)
6868
) {
6969
qs("#words")?.addClass("read_ahead_disabled");
@@ -452,7 +452,9 @@ const list: Partial<Record<FunboxName, FunboxFunctions>> = {
452452
}
453453
setTimeout(() => {
454454
highlight(
455-
TestWords.words.getCurrent().charAt(TestInput.input.current.length),
455+
TestWords.words
456+
.getCurrentText()
457+
.charAt(TestInput.input.current.length),
456458
);
457459
}, 1);
458460
}

frontend/src/ts/test/pace-caret.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ function incrementLetterIndex(): void {
195195
settings.currentLetterIndex++;
196196
if (
197197
settings.currentLetterIndex >=
198-
TestWords.words.get(settings.currentWordIndex).length + 1
198+
TestWords.words.getText(settings.currentWordIndex).length + 1
199199
) {
200200
//go to the next word
201201
settings.currentLetterIndex = 0;
@@ -208,7 +208,7 @@ function incrementLetterIndex(): void {
208208
if (settings.currentLetterIndex <= -2) {
209209
//go to the previous word
210210
settings.currentLetterIndex =
211-
TestWords.words.get(settings.currentWordIndex - 1).length - 1;
211+
TestWords.words.getText(settings.currentWordIndex - 1).length - 1;
212212
settings.currentWordIndex--;
213213
}
214214
settings.correction++;
@@ -218,7 +218,7 @@ function incrementLetterIndex(): void {
218218
settings.currentLetterIndex++;
219219
if (
220220
settings.currentLetterIndex >=
221-
TestWords.words.get(settings.currentWordIndex).length
221+
TestWords.words.getText(settings.currentWordIndex).length
222222
) {
223223
//go to the next word
224224
settings.currentLetterIndex = 0;

frontend/src/ts/test/practise-words.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,15 @@ export function init(
5555
let sortableMissedBiwords: [string, string, number][] = [];
5656
if (missed === "biwords") {
5757
for (let i = 0; i < TestWords.words.length; i++) {
58-
const missedWord = TestWords.words.get(i);
58+
const missedWord = TestWords.words.getText(i);
5959
const missedWordCount = TestInput.missedWords[missedWord];
6060
if (missedWordCount !== undefined) {
6161
if (i === 0) {
6262
sortableMissedBiwords.push([missedWord, "", missedWordCount]);
6363
} else {
6464
sortableMissedBiwords.push([
6565
missedWord,
66-
TestWords.words.get(i - 1),
66+
TestWords.words.getText(i - 1),
6767
missedWordCount,
6868
]);
6969
}
@@ -87,7 +87,7 @@ export function init(
8787
let sortableSlowWords: [string, number][] = [];
8888
if (slow) {
8989
const typedWords = TestWords.words
90-
.get()
90+
.getText()
9191
.slice(0, TestInput.input.getHistory().length - 1);
9292

9393
sortableSlowWords = typedWords.map((e, i) => [

0 commit comments

Comments
 (0)