Skip to content

Commit e70e12e

Browse files
committed
Fixed linting
1 parent f14b437 commit e70e12e

File tree

9 files changed

+38
-32
lines changed

9 files changed

+38
-32
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
".": "./lib/index.js",
1010
"./ExpireMap": "./lib/ExpireMap.js",
1111
"./HashMap": "./lib/HashMap.js",
12+
"./ObjectDoubleLinkedList": "./lib/ObjectDoubleLinkedList.js",
1213
"./ObjectLinkedList": "./lib/ObjectLinkedList.js",
1314
"./SortedMap": "./lib/SortedMap.js"
1415
},

src/DynamicBVH.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
// TODO
22

3-
//export class DynamicBVH {}
3+
// export class DynamicBVH {}

src/ExpireMap.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ export class ExpireMap<K, V> {
3232

3333
// if duplicate keys returns the index of the first one
3434
private _findIndexFirst(timestamp: number): number {
35-
let low = 0, high = this._expireTimes.length;
35+
let low = 0;
36+
let high = this._expireTimes.length;
3637
while(low < high){
3738
const mid = Math.floor((low + high) / 2);
3839
const cmp = timestamp - (this._expireTimes[mid] as number);
@@ -47,7 +48,8 @@ export class ExpireMap<K, V> {
4748

4849
// if duplicate keys returns the index of the last one
4950
private _findIndexLast(timestamp: number): number {
50-
let low = 0, high = this._expireTimes.length;
51+
let low = 0;
52+
let high = this._expireTimes.length;
5153
while(low < high){
5254
const mid = Math.floor((low + high) / 2);
5355
const cmp = timestamp - (this._expireTimes[mid] as number);

src/ObjectDoubleLinkedList.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -747,15 +747,15 @@ export class ObjectDoubleLinkedList<T extends LinkedListComparator<T>> {
747747

748748
// special case for head
749749
if(index === 0){
750-
const value = this._head.value;
750+
const oldHeadValue = this._head.value;
751751
this._head = this._head.next;
752752
if(this._head){
753753
this._head.prev = null;
754754
} else {
755755
this._tail = null;
756756
}
757757
this._size--;
758-
return value;
758+
return oldHeadValue;
759759
}
760760

761761
// iterate currNode.next to index
@@ -765,15 +765,15 @@ export class ObjectDoubleLinkedList<T extends LinkedListComparator<T>> {
765765
}
766766

767767
// currNode.next should be removed
768-
const value = currNode!.next!.value;
768+
const oldValue = currNode!.next!.value;
769769
if(currNode!.next!.next){
770770
currNode!.next!.next!.prev = currNode;
771771
} else {
772772
this._tail = currNode;
773773
}
774774
currNode!.next = currNode!.next!.next;
775775
this._size--;
776-
return value;
776+
return oldValue;
777777
}
778778

779779
/**
@@ -954,7 +954,7 @@ export class ObjectDoubleLinkedList<T extends LinkedListComparator<T>> {
954954
* @param size Amount of nodes that should remain linked to head.
955955
* @returns New head of the second part of the split linked list.
956956
*/
957-
function split<T>(head: DoubleLinkedListNode<T> | null, size: number): DoubleLinkedListNode<T> | null {
957+
function split<U>(head: DoubleLinkedListNode<U> | null, size: number): DoubleLinkedListNode<U> | null {
958958
let cur = head;
959959
for(let i = 1; cur && i < size; i++){
960960
cur = cur.next;
@@ -974,11 +974,11 @@ export class ObjectDoubleLinkedList<T extends LinkedListComparator<T>> {
974974
* @param compare Comparison function.
975975
* @returns Head and tail of the new merged list.
976976
*/
977-
function merge<T>(a: DoubleLinkedListNode<T> | null, b: DoubleLinkedListNode<T> | null, compare: (x: T, y: T) => number): { head: DoubleLinkedListNode<T> | null; tail: DoubleLinkedListNode<T> | null } {
977+
function merge<U>(a: DoubleLinkedListNode<U> | null, b: DoubleLinkedListNode<U> | null, compare: (x: U, y: U) => number): { head: DoubleLinkedListNode<U> | null; tail: DoubleLinkedListNode<U> | null } {
978978
// create new merged list
979-
let head: DoubleLinkedListNode<T> | null = null;
980-
let tail: DoubleLinkedListNode<T> | null = null;
981-
const append = (node: DoubleLinkedListNode<T>) => {
979+
let head: DoubleLinkedListNode<U> | null = null;
980+
let tail: DoubleLinkedListNode<U> | null = null;
981+
const append = (node: DoubleLinkedListNode<U>) => {
982982
node.prev = tail;
983983
node.next = null;
984984
if(tail) tail.next = node;
@@ -1131,7 +1131,7 @@ export class ObjectDoubleLinkedList<T extends LinkedListComparator<T>> {
11311131
* @return Array containing all values in the linked list.
11321132
*/
11331133
public toArray(): T[] {
1134-
const arr: Array<T> = new Array<T>(this._size);
1134+
const arr: T[] = new Array<T>(this._size);
11351135
let currNode = this._head;
11361136
for(let i=0; i < this._size; i++){
11371137
arr[i] = currNode!.value;

src/ObjectLinkedList.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -565,13 +565,13 @@ export class ObjectLinkedList<T extends LinkedListComparator<T>> {
565565

566566
// special case for head
567567
if(this._head.value.equals(lookup)){
568-
const value = this._head.value;
568+
const oldValue = this._head.value;
569569
this._head = this._head.next;
570570
if(!this._head){
571571
this._tail = null;
572572
}
573573
this._size--;
574-
return value;
574+
return oldValue;
575575
}
576576

577577
// iterate currNode.next to index
@@ -646,12 +646,12 @@ export class ObjectLinkedList<T extends LinkedListComparator<T>> {
646646

647647
// special case for head
648648
if(index === 0){
649-
const value = this._head.value;
649+
const oldHeadValue = this._head.value;
650650
this._head = this._head.next;
651651
if(!this._head){
652652
this._tail = null;
653653
}
654-
return value;
654+
return oldHeadValue;
655655
}
656656

657657
// iterate currNode.next to index
@@ -661,13 +661,13 @@ export class ObjectLinkedList<T extends LinkedListComparator<T>> {
661661
}
662662

663663
// currNode.next should be removed
664-
const value = currNode!.next!.value;
664+
const oldValue = currNode!.next!.value;
665665
if(!currNode!.next!.next){
666666
this._tail = currNode;
667667
}
668668
currNode!.next = currNode!.next!.next;
669669
this._size--;
670-
return value;
670+
return oldValue;
671671
}
672672

673673
/**
@@ -845,7 +845,7 @@ export class ObjectLinkedList<T extends LinkedListComparator<T>> {
845845
* @param size Amount of nodes that should remain linked to head.
846846
* @returns New head of the second part of the split linked list.
847847
*/
848-
function split<T>(head: LinkedListNode<T> | null, size: number): LinkedListNode<T> | null {
848+
function split<U>(head: LinkedListNode<U> | null, size: number): LinkedListNode<U> | null {
849849
let cur = head;
850850
for(let i = 1; cur && i < size; i++){
851851
cur = cur.next;
@@ -864,11 +864,11 @@ export class ObjectLinkedList<T extends LinkedListComparator<T>> {
864864
* @param compare Comparison function.
865865
* @returns Head and tail of the new merged list.
866866
*/
867-
function merge<T>(a: LinkedListNode<T> | null, b: LinkedListNode<T> | null, compare: (x: T, y: T) => number): { head: LinkedListNode<T> | null; tail: LinkedListNode<T> | null } {
867+
function merge<U>(a: LinkedListNode<U> | null, b: LinkedListNode<U> | null, compare: (x: U, y: U) => number): { head: LinkedListNode<U> | null; tail: LinkedListNode<U> | null } {
868868
// create new merged list
869-
let head: LinkedListNode<T> | null = null;
870-
let tail: LinkedListNode<T> | null = null;
871-
const append = (node: LinkedListNode<T>) => {
869+
let head: LinkedListNode<U> | null = null;
870+
let tail: LinkedListNode<U> | null = null;
871+
const append = (node: LinkedListNode<U>) => {
872872
node.next = null;
873873
if(tail) tail.next = node;
874874
else head = node;
@@ -1012,7 +1012,7 @@ export class ObjectLinkedList<T extends LinkedListComparator<T>> {
10121012
* @return Array containing all values in the linked list.
10131013
*/
10141014
public toArray(): T[] {
1015-
const arr: Array<T> = new Array<T>(this._size);
1015+
const arr: T[] = new Array<T>(this._size);
10161016
let currNode = this._head;
10171017
for(let i=0; i < this._size; i++){
10181018
arr[i] = currNode!.value;

src/SortedMap.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ export class SortedMap<K, V> {
3333
}
3434

3535
private _findIndex(key: K): {index: number, alreadyExists: boolean } {
36-
let low = 0, high = this.size;
36+
let low = 0;
37+
let high = this.size;
3738
while(low < high){
3839
const mid = Math.floor((low + high) / 2);
3940
const cmp = this.compare(key, this.myKeys[mid]);
@@ -215,7 +216,7 @@ export class SortedMap<K, V> {
215216
const value = self.myValues[idx] as V;
216217
idx++;
217218
if(k < key || (inclusive && k === key))
218-
return { value: value, done: false };
219+
return { value, done: false };
219220
}
220221
return { value: undefined, done: true };
221222
},
@@ -237,7 +238,7 @@ export class SortedMap<K, V> {
237238
const value = self.myValues[idx] as V;
238239
idx++;
239240
if(k > key || (inclusive && k === key))
240-
return { value: value, done: false };
241+
return { value, done: false };
241242
}
242243
return { value: undefined, done: true };
243244
},

src/__tests__/ExpireMap.test.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,9 +269,7 @@ describe('Testing ExpireMap', () => {
269269

270270
await sleep(25);
271271

272-
console.log(map.toDebugString()); // TODO REMOVE
273272
map.get("a"); // should reset lifespan of elements
274-
console.log(map.toDebugString()); // TODO REMOVE
275273
map.get("c"); // should reset lifespan of elements
276274
expect(map.getRemainingLifespan("a")).toBeLessThanOrEqual(50);
277275
expect(map.getRemainingLifespan("a")).toBeGreaterThan(25);

src/__tests__/ObjectDoubleLinkedList.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -997,7 +997,6 @@ describe('Testing LinkedList', () => {
997997
]);
998998

999999
const resultA = listA.splice(0, 2, new TestEntry(1));
1000-
console.log(resultA, listA.toDebugString()); // TODO REMOVE
10011000
expect(listA.length).toBe(1);
10021001
expect(listA.at(0)?.value).toBe(1);
10031002
expect(listA.at(1)).toBeUndefined();

tslint.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
{
2-
"extends": ["tslint:recommended", "tslint-config-prettier"]
2+
"extends": ["tslint:recommended", "tslint-config-prettier"],
3+
"rules": {
4+
"max-classes-per-file": false,
5+
"no-bitwise": false,
6+
"prefer-for-of": false
7+
}
38
}

0 commit comments

Comments
 (0)