From: Shinigami Date: Mon, 8 Feb 2021 21:05:53 +0000 (+0100) Subject: Remove usage of module.exports (#84) X-Git-Tag: v2.0.0-beta.2~73 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=60fbd6d6188b0902d157fd0cde04d6af3a391e32;p=poolifier.git Remove usage of module.exports (#84) --- diff --git a/examples/dynamicExample.js b/examples/dynamicExample.js index 22379f20..22b4f19c 100644 --- a/examples/dynamicExample.js +++ b/examples/dynamicExample.js @@ -1,4 +1,4 @@ -const DynamicThreadPool = require('../lib/dynamic') +const { DynamicThreadPool } = require('poolifier') let resolved = 0 let maxReached = 0 const pool = new DynamicThreadPool(10, 20, './yourWorker.js', { diff --git a/examples/multiFunctionExample.js b/examples/multiFunctionExample.js index 76b6bbfb..d1314aa9 100644 --- a/examples/multiFunctionExample.js +++ b/examples/multiFunctionExample.js @@ -1,4 +1,4 @@ -const FixedThreadPool = require('../lib/fixed') +const { FixedThreadPool } = require('poolifier') const pool = new FixedThreadPool(15, './multifunctionWorker.js', { errorHandler: e => console.error(e), onlineHandler: () => console.log('worker is online') diff --git a/examples/multifunctionWorker.js b/examples/multifunctionWorker.js index f3efb452..8a1809ac 100644 --- a/examples/multifunctionWorker.js +++ b/examples/multifunctionWorker.js @@ -1,5 +1,5 @@ 'use strict' -const { ThreadWorker } = require('../lib/workers') +const { ThreadWorker } = require('poolifier') function yourFunction (data) { if (data.fname === 'fn0') { diff --git a/examples/staticExample.js b/examples/staticExample.js index b9f7503f..f125c477 100644 --- a/examples/staticExample.js +++ b/examples/staticExample.js @@ -1,4 +1,4 @@ -const FixedThreadPool = require('../lib/fixed') +const { FixedThreadPool } = require('poolifier') let resolved = 0 const pool = new FixedThreadPool(15, './yourWorker.js', { errorHandler: e => console.error(e), diff --git a/examples/yourWorker.js b/examples/yourWorker.js index ac3959d1..4597f648 100644 --- a/examples/yourWorker.js +++ b/examples/yourWorker.js @@ -1,5 +1,5 @@ 'use strict' -const { ThreadWorker } = require('../lib/workers') +const { ThreadWorker } = require('poolifier') function yourFunction (data) { for (let i = 0; i <= 1000; i++) { diff --git a/src/dynamic.ts b/src/dynamic.ts index 211141ca..ca6e4849 100644 --- a/src/dynamic.ts +++ b/src/dynamic.ts @@ -1,6 +1,7 @@ /* eslint-disable @typescript-eslint/strict-boolean-expressions */ -import FixedThreadPool, { +import { + FixedThreadPool, FixedThreadPoolOptions, WorkerWithMessageChannel } from './fixed' @@ -20,7 +21,7 @@ export type DynamicThreadPoolOptions = FixedThreadPoolOptions * @author [Alessandro Pio Ardizio](https://github.com/pioardi) * @since 0.0.1 */ -export default class DynamicThreadPool< +export class DynamicThreadPool< Data = any, Response = any > extends FixedThreadPool { @@ -77,5 +78,3 @@ export default class DynamicThreadPool< } } } - -module.exports = DynamicThreadPool diff --git a/src/fixed.ts b/src/fixed.ts index 3ca43cdb..39ee5954 100644 --- a/src/fixed.ts +++ b/src/fixed.ts @@ -38,7 +38,7 @@ export interface FixedThreadPoolOptions { * @author [Alessandro Pio Ardizio](https://github.com/pioardi) * @since 0.0.1 */ -export default class FixedThreadPool { +export class FixedThreadPool { public readonly workers: WorkerWithMessageChannel[] = [] public nextWorker: number = 0 @@ -161,5 +161,3 @@ export default class FixedThreadPool { return worker } } - -module.exports = FixedThreadPool diff --git a/src/index.ts b/src/index.ts index db6960b8..1d7e0b1f 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,5 +1,5 @@ -import DynamicThreadPool from './dynamic' -import FixedThreadPool from './fixed' +import { DynamicThreadPool } from './dynamic' +import { FixedThreadPool } from './fixed' import { ThreadWorker } from './workers' export { @@ -10,5 +10,3 @@ export { export { DynamicThreadPoolOptions } from './dynamic' export { ThreadWorkerOptions } from './workers' export { FixedThreadPool, DynamicThreadPool, ThreadWorker } - -module.exports = { FixedThreadPool, DynamicThreadPool, ThreadWorker } diff --git a/tests/dynamic.test.js b/tests/dynamic.test.js index 67f55041..5b16a361 100644 --- a/tests/dynamic.test.js +++ b/tests/dynamic.test.js @@ -1,5 +1,5 @@ const expect = require('expect') -const DynamicThreadPool = require('../lib/dynamic') +const { DynamicThreadPool } = require('../lib/dynamic') const min = 1 const max = 3 const pool = new DynamicThreadPool(min, max, './tests/workers/testWorker.js', { diff --git a/tests/fixed.test.js b/tests/fixed.test.js index 604ef80c..12c705cc 100644 --- a/tests/fixed.test.js +++ b/tests/fixed.test.js @@ -1,5 +1,5 @@ const expect = require('expect') -const FixedThreadPool = require('../lib/fixed') +const { FixedThreadPool } = require('../lib/fixed') const numThreads = 10 const pool = new FixedThreadPool(numThreads, './tests/workers/testWorker.js', { errorHandler: e => console.error(e),