From fe6df2852c1f0964cdffb0698461c9d66b1cf7ed Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Fri, 28 Jun 2024 12:27:21 +0200 Subject: [PATCH] refactor: code reformatting MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- eslint.config.js | 8 ++++++- src/pools/abstract-pool.ts | 4 ++-- tests/pools/abstract-pool.test.mjs | 35 +++++++++++++++--------------- 3 files changed, 26 insertions(+), 21 deletions(-) diff --git a/eslint.config.js b/eslint.config.js index 6288f9b9..a7368892 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -19,7 +19,13 @@ export default defineFlatConfig([ jsdoc.configs['flat/recommended-typescript'], { rules: { - 'jsdoc/check-tag-names': ['warn', { typed: true, definedTags: ['defaultValue', 'experimental', 'typeParam'] }], + 'jsdoc/check-tag-names': [ + 'warn', + { + typed: true, + definedTags: ['defaultValue', 'experimental', 'typeParam'], + }, + ], }, }, ...tseslint.config( diff --git a/src/pools/abstract-pool.ts b/src/pools/abstract-pool.ts index 76dca07a..603409f0 100644 --- a/src/pools/abstract-pool.ts +++ b/src/pools/abstract-pool.ts @@ -1125,14 +1125,14 @@ export abstract class AbstractPool< return new Set([ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion this.opts.workerChoiceStrategy!, - ...(this.listTaskFunctionsProperties() + ...this.listTaskFunctionsProperties() .map( (taskFunctionProperties: TaskFunctionProperties) => taskFunctionProperties.strategy ) .filter( (strategy: WorkerChoiceStrategy | undefined) => strategy != null - )), + ), ]) } diff --git a/tests/pools/abstract-pool.test.mjs b/tests/pools/abstract-pool.test.mjs index ecb1c567..7661bf67 100644 --- a/tests/pools/abstract-pool.test.mjs +++ b/tests/pools/abstract-pool.test.mjs @@ -1714,32 +1714,31 @@ describe('Abstract pool test suite', () => { numberOfWorkers, './tests/worker-files/thread/testMultipleTaskFunctionsWorker.mjs' ) - expect(() => pool.mapExecute()).toThrow(new TypeError('data argument must be a defined iterable')) - expect(() => pool.mapExecute(0)).toThrow(new TypeError('data argument must be an iterable')) + expect(() => pool.mapExecute()).toThrow( + new TypeError('data argument must be a defined iterable') + ) + expect(() => pool.mapExecute(0)).toThrow( + new TypeError('data argument must be an iterable') + ) let results = await pool.mapExecute([{}, {}, {}, {}]) - expect(results).toStrictEqual([ - { ok: 1 }, - { ok: 1 }, - { ok: 1 }, - { ok: 1 }, - ]) + expect(results).toStrictEqual([{ ok: 1 }, { ok: 1 }, { ok: 1 }, { ok: 1 }]) expect(pool.info.executingTasks).toBe(0) expect(pool.info.executedTasks).toBe(4) - results = await pool.mapExecute([{ n: 10 }, { n: 20 }, { n: 30 }, { n: 40 }], 'factorial') + results = await pool.mapExecute( + [{ n: 10 }, { n: 20 }, { n: 30 }, { n: 40 }], + 'factorial' + ) expect(results).toStrictEqual([ - 3628800, - 2432902008176640000, - 2.6525285981219103e+32, - 8.159152832478977e+47, + 3628800, 2432902008176640000, 2.6525285981219103e32, 8.159152832478977e47, ]) expect(pool.info.executingTasks).toBe(0) expect(pool.info.executedTasks).toBe(8) - results = await pool.mapExecute(new Set([{ n: 10 }, { n: 20 }, { n: 30 }, { n: 40 }]), 'factorial') + results = await pool.mapExecute( + new Set([{ n: 10 }, { n: 20 }, { n: 30 }, { n: 40 }]), + 'factorial' + ) expect(results).toStrictEqual([ - 3628800, - 2432902008176640000, - 2.6525285981219103e+32, - 8.159152832478977e+47, + 3628800, 2432902008176640000, 2.6525285981219103e32, 8.159152832478977e47, ]) expect(pool.info.executingTasks).toBe(0) expect(pool.info.executedTasks).toBe(12) -- 2.34.1