From 5708174f40c83783631f584c2d7f0a264fa78b20 Mon Sep 17 00:00:00 2001 From: Lyudmil Danailov Date: Wed, 24 Jan 2024 17:50:14 +0200 Subject: [PATCH] Renaming taskManager map property --- lib/task_manager.js | 10 +++++----- test/lib/task_manager.spec.js | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/task_manager.js b/lib/task_manager.js index 607c3f9c..e546d650 100644 --- a/lib/task_manager.js +++ b/lib/task_manager.js @@ -1,6 +1,6 @@ class TaskManager { constructor() { - this.map = {}; + this.taskData = {}; this.queue; this.buffer = []; this.lastPushedToBuffer = 0; @@ -39,8 +39,8 @@ class TaskManager { } #pushAllEligable() { - while (this.map[this.lastPushedToBuffer]) { - for (const data of this.map[this.lastPushedToBuffer]) { + while (this.taskData[this.lastPushedToBuffer]) { + for (const data of this.taskData[this.lastPushedToBuffer]) { this.buffer.push(data); this.lastProcessedPosition = { primaryKey: this.buffer[this.buffer.length - 1].primaryKey, @@ -48,13 +48,13 @@ class TaskManager { }; } - delete this.map[this.lastPushedToBuffer]; + delete this.taskData[this.lastPushedToBuffer]; this.lastPushedToBuffer++; } } handleNewData([key, newTransformedData]) { - this.map[key] = newTransformedData; + this.taskData[key] = newTransformedData; this.#pushAllEligable(); } diff --git a/test/lib/task_manager.spec.js b/test/lib/task_manager.spec.js index 279fd2a6..85d62678 100644 --- a/test/lib/task_manager.spec.js +++ b/test/lib/task_manager.spec.js @@ -5,7 +5,7 @@ describe('TaskManager', () => { it('constructor initializes corresponding variables', () => { const taskManager = new TaskManager(); - assert.deepStrictEqual(taskManager.map, {}); + assert.deepStrictEqual(taskManager.taskData, {}); assert.deepStrictEqual(taskManager.buffer, []); assert.strictEqual(taskManager.lastPushedToBuffer, 0); assert.strictEqual(taskManager.queue, undefined); @@ -33,7 +33,7 @@ describe('TaskManager', () => { const exampleDataObject = [{ fromBlock: 1, toBlock: 10, data: [1, 2, 3] }]; taskManager.handleNewData([1, exampleDataObject]); // This [key, data] pair comes from the worker's work method - assert.deepStrictEqual(taskManager.map, {1: exampleDataObject}); + assert.deepStrictEqual(taskManager.taskData, {1: exampleDataObject}); }); it('handleNewData() fills the buffer accordingly', () => {