From 3cfd603f8471c5e513f906b3a27f39d14534b342 Mon Sep 17 00:00:00 2001 From: Hakaabi Date: Thu, 19 Sep 2024 12:57:42 +0300 Subject: [PATCH 1/2] Edited batch.js in codhers --- src/batch.js | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/batch.js b/src/batch.js index 48c6571cd4..21706d773d 100644 --- a/src/batch.js +++ b/src/batch.js @@ -10,12 +10,23 @@ const DEFAULT_BATCH_SIZE = 100; const sleep = util.promisify(setTimeout); -exports.processSortedSet = async function (setKey, process, options) { - options = options || {}; +// I will reduce the complexity of the code by making helper functions outside the main function +// where the errors show +// helper functions: +// fixing error 1: +function processIsFunction(process) { if (typeof process !== 'function') { throw new Error('[[error:process-not-a-function]]'); } +} + + +exports.processSortedSet = async function (setKey, process, options) { + console.log('Hakaabi: Refactored code is running!'); + options = options || {}; + + processIsFunction(process); // Progress bar handling (upgrade scripts) if (options.progress) { @@ -68,6 +79,7 @@ exports.processSortedSet = async function (setKey, process, options) { stop = start + options.batch - 1; } }; +console.log('Hakaabi: Refactored code stopped running!'); exports.processArray = async function (array, process, options) { options = options || {}; @@ -101,4 +113,4 @@ exports.processArray = async function (array, process, options) { } }; -require('./promisify')(exports); +require('./promisify')(exports); \ No newline at end of file From 78e2a19839508eecc5458ae82f9f0db52538c748 Mon Sep 17 00:00:00 2001 From: Hakaabi Date: Thu, 19 Sep 2024 13:07:51 +0300 Subject: [PATCH 2/2] fixxing config.json port --- src/batch.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/batch.js b/src/batch.js index 21706d773d..208371fca1 100644 --- a/src/batch.js +++ b/src/batch.js @@ -113,4 +113,4 @@ exports.processArray = async function (array, process, options) { } }; -require('./promisify')(exports); \ No newline at end of file +require('./promisify')(exports);