Skip to content

Commit

Permalink
Migrate to TS to get better code completion
Browse files Browse the repository at this point in the history
  • Loading branch information
tavaresasilva committed Jul 3, 2024
1 parent 94900f6 commit 0405843
Show file tree
Hide file tree
Showing 24 changed files with 722 additions and 660 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto eol=lf
118 changes: 59 additions & 59 deletions demo/assets/bundle.js

Large diffs are not rendered by default.

142 changes: 142 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
"copyfiles": "^2.4.1",
"css-loader": "^7.1.2",
"mini-css-extract-plugin": "^2.9.0",
"ts-loader": "^9.5.1",
"typescript": "^5.5.3",
"webpack": "^5.92.0",
"webpack-cli": "^5.1.4"
}
Expand Down
16 changes: 10 additions & 6 deletions src/commands/command-factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,15 @@ class Command {
}

execute() {
if (this.elements !== null) {
this.operation(...this.elements);
} else {
this.operation();
}

setTimeout(() => {
if (this.elements !== null) {
this.operation(...this.elements);
} else {
this.operation();
}
}, 0);

}
}

Expand Down Expand Up @@ -57,7 +61,7 @@ export const OPERATIONS = {
TOGGLE_CHANGE_COLOR_BOX: 'toggle-change-color-box',
TOGGLE_TURN_INTO_BOX: 'toggle-turn-into-box',
TOGGLE_INPUT_LINK_BOX: 'toggle-input-link-box',
INPUT_LINK_URL: 'input-link-url',
INPUT_LINK_URL: 'input-link-url',
TOGGLE_ENCLOSE_SELECTED_TEXT_TO: 'toggle-enclose-selected-text-to',
},

Expand Down
62 changes: 0 additions & 62 deletions src/common/JCircularLinkedList.js

This file was deleted.

46 changes: 46 additions & 0 deletions src/common/JCircularLinkedList.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import JNode from './JNode';

class JCircularLinkedList<T extends JNode<T>> {

head: T | null = null;
tail: T | null = null;

length: number = 0;

constructor() {

}

append(node: T): void {

if (!this.head || !this.tail) {

this.head = node;
this.tail = node;

this.head.setNext(this.tail);
this.head.setPrevious(this.tail);

} else {
node.setPrevious(this.tail);
node.setNext(this.head);

this.tail.setNext(node);
this.head.setPrevious(node);

this.tail = node;
}

this.length++;
}

getFirst(): T | null {
return this.head;
}

getLast(): T | null {
return this.tail;
}
}

export default JCircularLinkedList;
Loading

0 comments on commit 0405843

Please sign in to comment.