refactor: use delete on properties
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Mon, 25 Sep 2023 09:10:45 +0000 (11:10 +0200)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Mon, 25 Sep 2023 09:10:45 +0000 (11:10 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
src/deque.ts
src/pools/selection-strategies/abstract-worker-choice-strategy.ts
tests/worker/abstract-worker.test.js

index 2eae8034845789b4991c3d1435c24f7050726c42..723f1a4950688bcea0244e83a8f764b02cdf5a38 100644 (file)
@@ -76,14 +76,14 @@ export class Deque<T> {
    */
   public pop (): T | undefined {
     if (this.head == null) {
-      return undefined
+      return
     }
     const tail = this.tail
     this.tail = (this.tail as Node<T>).prev
     if (this.tail == null) {
-      this.head = undefined
+      delete this.head
     } else {
-      this.tail.next = undefined
+      delete this.tail.next
     }
     --this.size
     return tail?.data
@@ -96,14 +96,14 @@ export class Deque<T> {
    */
   public shift (): T | undefined {
     if (this.head == null) {
-      return undefined
+      return
     }
     const head = this.head
     this.head = this.head.next
     if (this.head == null) {
-      this.tail = undefined
+      delete this.tail
     } else {
-      this.head.prev = undefined
+      delete this.head.prev
     }
     --this.size
     return head?.data
@@ -129,8 +129,8 @@ export class Deque<T> {
    * Clears the deque.
    */
   public clear (): void {
-    this.head = undefined
-    this.tail = undefined
+    delete this.head
+    delete this.tail
     this.size = 0
     this.maxSize = 0
   }
index 5ec7cedc0f9dc0f2f4a1079302a94d515c5d4281..630a2258be49a7ed725f12b1ac555d510dd0e257 100644 (file)
@@ -208,7 +208,7 @@ export abstract class AbstractWorkerChoiceStrategy<
    */
   protected checkNextWorkerNodeEligibility (): void {
     if (!this.isWorkerNodeEligible(this.nextWorkerNodeKey as number)) {
-      this.nextWorkerNodeKey = undefined
+      delete this.nextWorkerNodeKey
     }
   }
 
index 200b05acdff0f26a29c0eb4e2e760a64448935f5..1b055217b3e6405b59bf492980e578b1c600ef78 100644 (file)
@@ -7,7 +7,7 @@ describe('Abstract worker test suite', () => {
   class StubWorkerWithMainWorker extends ThreadWorker {
     constructor (fn, opts) {
       super(fn, opts)
-      this.mainWorker = undefined
+      delete this.mainWorker
     }
   }