From: Jérôme Benoit Date: Wed, 20 Sep 2023 20:02:40 +0000 (+0200) Subject: refactor: cleanup type import X-Git-Tag: v2.7.2~25 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=ef083f7bb73616d1bd9d9069471edcf6dbaec0c7;hp=51e49c70379025e6709ae33e5cb4bf91b22ccc41;p=poolifier.git refactor: cleanup type import Signed-off-by: Jérôme Benoit --- diff --git a/examples/typescript/http-client-pool/src/main.ts b/examples/typescript/http-client-pool/src/main.ts index 8217434f..41028e63 100644 --- a/examples/typescript/http-client-pool/src/main.ts +++ b/examples/typescript/http-client-pool/src/main.ts @@ -1,6 +1,6 @@ import { availableParallelism } from 'poolifier' import { httpClientPool } from './pool.js' -import { type WorkerResponse } from './types.js' +import type { WorkerResponse } from './types.js' const parallelism = availableParallelism() * 2 const requestUrl = 'http://localhost:8080/' diff --git a/examples/typescript/http-client-pool/src/pool.ts b/examples/typescript/http-client-pool/src/pool.ts index 3d64150a..7fbb20d5 100644 --- a/examples/typescript/http-client-pool/src/pool.ts +++ b/examples/typescript/http-client-pool/src/pool.ts @@ -1,7 +1,7 @@ import { fileURLToPath } from 'node:url' import { dirname, extname, join } from 'node:path' import { DynamicThreadPool, availableParallelism } from 'poolifier' -import { type WorkerData, type WorkerResponse } from './types.js' +import type { WorkerData, WorkerResponse } from './types.js' const workerFile = join( dirname(fileURLToPath(import.meta.url)), diff --git a/examples/typescript/http-client-pool/src/types.ts b/examples/typescript/http-client-pool/src/types.ts index ff0d3262..11fe73e8 100644 --- a/examples/typescript/http-client-pool/src/types.ts +++ b/examples/typescript/http-client-pool/src/types.ts @@ -1,9 +1,9 @@ -import { type URL } from 'node:url' +import type { URL } from 'node:url' import { type RequestInfo as NodeFetchRequestInfo, type RequestInit as NodeFetchRequestInit } from 'node-fetch' -import { type AxiosRequestConfig } from 'axios' +import type { AxiosRequestConfig } from 'axios' export interface WorkerData { input: URL | RequestInfo | NodeFetchRequestInfo diff --git a/examples/typescript/http-client-pool/src/worker.ts b/examples/typescript/http-client-pool/src/worker.ts index b7c59629..63f77fd7 100644 --- a/examples/typescript/http-client-pool/src/worker.ts +++ b/examples/typescript/http-client-pool/src/worker.ts @@ -4,7 +4,7 @@ import nodeFetch, { type ResponseInit as NodeFetchRequestInit } from 'node-fetch' import axios from 'axios' -import { type WorkerData, type WorkerResponse } from './types.js' +import type { WorkerData, WorkerResponse } from './types.js' class HttpClientWorker extends ThreadWorker { public constructor () { diff --git a/examples/typescript/http-server-pool/express-cluster/src/worker.ts b/examples/typescript/http-server-pool/express-cluster/src/worker.ts index c5fe74ac..7dd607b5 100644 --- a/examples/typescript/http-server-pool/express-cluster/src/worker.ts +++ b/examples/typescript/http-server-pool/express-cluster/src/worker.ts @@ -2,7 +2,7 @@ import type { Server } from 'node:http' import type { AddressInfo } from 'node:net' import { ClusterWorker } from 'poolifier' import express, { type Express, type Request, type Response } from 'express' -import { type WorkerData, type WorkerResponse } from './types.js' +import type { WorkerData, WorkerResponse } from './types.js' const factorial: (n: number) => number = n => { if (n === 0) { diff --git a/examples/typescript/http-server-pool/fastify-hybrid/@types/fastify/index.d.ts b/examples/typescript/http-server-pool/fastify-hybrid/@types/fastify/index.d.ts index 70a804b1..3ff88aa2 100644 --- a/examples/typescript/http-server-pool/fastify-hybrid/@types/fastify/index.d.ts +++ b/examples/typescript/http-server-pool/fastify-hybrid/@types/fastify/index.d.ts @@ -1,6 +1,6 @@ import type { TransferListItem } from 'node:worker_threads' import type * as fastify from 'fastify' -import { type DynamicThreadPool } from 'poolifier' +import type { DynamicThreadPool } from 'poolifier' import { type ThreadWorkerData, type ThreadWorkerResponse diff --git a/examples/typescript/http-server-pool/fastify-hybrid/src/fastify-poolifier.ts b/examples/typescript/http-server-pool/fastify-hybrid/src/fastify-poolifier.ts index 2d137580..2bdf2040 100644 --- a/examples/typescript/http-server-pool/fastify-hybrid/src/fastify-poolifier.ts +++ b/examples/typescript/http-server-pool/fastify-hybrid/src/fastify-poolifier.ts @@ -1,6 +1,6 @@ import type { TransferListItem } from 'node:worker_threads' import { DynamicThreadPool, availableParallelism } from 'poolifier' -import { type FastifyPluginCallback } from 'fastify' +import type { FastifyPluginCallback } from 'fastify' import fp from 'fastify-plugin' import { type FastifyPoolifierOptions, diff --git a/examples/typescript/http-server-pool/fastify-worker_threads/@types/fastify/index.d.ts b/examples/typescript/http-server-pool/fastify-worker_threads/@types/fastify/index.d.ts index e2ec4062..93fb69eb 100644 --- a/examples/typescript/http-server-pool/fastify-worker_threads/@types/fastify/index.d.ts +++ b/examples/typescript/http-server-pool/fastify-worker_threads/@types/fastify/index.d.ts @@ -1,7 +1,7 @@ import type { TransferListItem } from 'node:worker_threads' import type * as fastify from 'fastify' -import { type DynamicThreadPool } from 'poolifier' -import { type WorkerData, type WorkerResponse } from '../../src/types.ts' +import type { DynamicThreadPool } from 'poolifier' +import type { WorkerData, WorkerResponse } from '../../src/types.ts' declare module 'fastify' { export interface FastifyInstance extends fastify.FastifyInstance { diff --git a/examples/typescript/http-server-pool/fastify-worker_threads/src/fastify-poolifier.ts b/examples/typescript/http-server-pool/fastify-worker_threads/src/fastify-poolifier.ts index 74c0c168..aa9a6d14 100644 --- a/examples/typescript/http-server-pool/fastify-worker_threads/src/fastify-poolifier.ts +++ b/examples/typescript/http-server-pool/fastify-worker_threads/src/fastify-poolifier.ts @@ -1,6 +1,6 @@ import type { TransferListItem } from 'node:worker_threads' import { DynamicThreadPool, availableParallelism } from 'poolifier' -import { type FastifyPluginCallback } from 'fastify' +import type { FastifyPluginCallback } from 'fastify' import fp from 'fastify-plugin' import { type FastifyPoolifierOptions, diff --git a/examples/typescript/http-server-pool/fastify-worker_threads/src/types.ts b/examples/typescript/http-server-pool/fastify-worker_threads/src/types.ts index 9e0cf696..97c2c540 100644 --- a/examples/typescript/http-server-pool/fastify-worker_threads/src/types.ts +++ b/examples/typescript/http-server-pool/fastify-worker_threads/src/types.ts @@ -1,4 +1,4 @@ -import { type ThreadPoolOptions } from 'poolifier' +import type { ThreadPoolOptions } from 'poolifier' export interface BodyPayload { number?: number diff --git a/examples/typescript/smtp-client-pool/src/pool.ts b/examples/typescript/smtp-client-pool/src/pool.ts index ec2ec136..85fb4cdf 100644 --- a/examples/typescript/smtp-client-pool/src/pool.ts +++ b/examples/typescript/smtp-client-pool/src/pool.ts @@ -2,7 +2,7 @@ import { fileURLToPath } from 'node:url' import { dirname, extname, join } from 'node:path' import { DynamicThreadPool, availableParallelism } from 'poolifier' import type SMTPTransport from 'nodemailer/lib/smtp-transport/index.js' -import { type WorkerData } from './types.js' +import type { WorkerData } from './types.js' const workerFile = join( dirname(fileURLToPath(import.meta.url)), diff --git a/examples/typescript/smtp-client-pool/src/worker.ts b/examples/typescript/smtp-client-pool/src/worker.ts index 3ac62cca..448575d1 100644 --- a/examples/typescript/smtp-client-pool/src/worker.ts +++ b/examples/typescript/smtp-client-pool/src/worker.ts @@ -2,7 +2,7 @@ import { ThreadWorker } from 'poolifier' import { createTransport } from 'nodemailer' import type Mail from 'nodemailer/lib/mailer/index.js' import type SMTPTransport from 'nodemailer/lib/smtp-transport/index.js' -import { type WorkerData } from './types.js' +import type { WorkerData } from './types.js' class SmtpClientWorker extends ThreadWorker< WorkerData, diff --git a/examples/typescript/websocket-server-pool/ws-cluster/src/main.ts b/examples/typescript/websocket-server-pool/ws-cluster/src/main.ts index ad58bd20..6187d71f 100644 --- a/examples/typescript/websocket-server-pool/ws-cluster/src/main.ts +++ b/examples/typescript/websocket-server-pool/ws-cluster/src/main.ts @@ -1,7 +1,7 @@ import { dirname, extname, join } from 'node:path' import { fileURLToPath } from 'node:url' import { FixedClusterPool, availableParallelism } from 'poolifier' -import { type WorkerData, type WorkerResponse } from './types.js' +import type { WorkerData, WorkerResponse } from './types.js' const workerFile = join( dirname(fileURLToPath(import.meta.url)), diff --git a/examples/typescript/websocket-server-pool/ws-hybrid/src/main.ts b/examples/typescript/websocket-server-pool/ws-hybrid/src/main.ts index f6536bd0..3adac7e8 100644 --- a/examples/typescript/websocket-server-pool/ws-hybrid/src/main.ts +++ b/examples/typescript/websocket-server-pool/ws-hybrid/src/main.ts @@ -1,7 +1,7 @@ import { dirname, extname, join } from 'node:path' import { fileURLToPath } from 'node:url' import { FixedClusterPool, availableParallelism } from 'poolifier' -import { type ClusterWorkerData, type ClusterWorkerResponse } from './types.js' +import type { ClusterWorkerData, ClusterWorkerResponse } from './types.js' const webSocketServerWorkerFile = join( dirname(fileURLToPath(import.meta.url)), diff --git a/src/pools/abstract-pool.ts b/src/pools/abstract-pool.ts index 4fe0c038..e525cc9a 100644 --- a/src/pools/abstract-pool.ts +++ b/src/pools/abstract-pool.ts @@ -1,6 +1,6 @@ import { randomUUID } from 'node:crypto' import { performance } from 'node:perf_hooks' -import { type TransferListItem } from 'node:worker_threads' +import type { TransferListItem } from 'node:worker_threads' import type { MessageValue, PromiseResponseWrapper, diff --git a/src/pools/pool.ts b/src/pools/pool.ts index ab2cf2e4..f0c7d886 100644 --- a/src/pools/pool.ts +++ b/src/pools/pool.ts @@ -1,5 +1,5 @@ import { EventEmitter } from 'node:events' -import { type TransferListItem } from 'node:worker_threads' +import type { TransferListItem } from 'node:worker_threads' import type { TaskFunction } from '../worker/task-functions' import type { ErrorHandler,