Skip to content

Commit 2aad375

Browse files
committed
dev: Fixed circular typing dependencies
1 parent 14e8742 commit 2aad375

File tree

7 files changed

+23
-28
lines changed

7 files changed

+23
-28
lines changed

src/constants.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
export enum PoolState {
2+
IDLE = 0,
3+
STARTED = 1,
4+
CLOSING = 2,
5+
CLOSED = 3,
6+
}
7+
8+
export enum ResourceState {
9+
IDLE = 0,
10+
ACQUIRED = 1,
11+
VALIDATION = 2,
12+
}

src/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
import { PoolConfiguration, PoolFactory } from './definitions.js';
21
import { Pool } from './pool.js';
2+
import { PoolConfiguration, PoolFactory } from './types.js';
33

44
export * from './abort-error.js';
5-
export * from './definitions.js';
5+
export * from './constants.js';
66
export * from './pool.js';
7+
export * from './types.js';
78

89
export function createPool<T = any>(
910
factory: PoolFactory<T>,

src/pool-options.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { EventEmitter } from 'events';
2-
import { PoolConfiguration } from './definitions.js';
3-
import { Pool } from './pool.js';
2+
import type { Pool } from './pool.js';
3+
import type { PoolConfiguration } from './types.js';
44

55
const defaultValues = {
66
acquireMaxRetries: 0,

src/pool-request.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { Callback } from './definitions.js';
2-
import { Pool } from './pool.js';
1+
import type { Pool } from './pool.js';
2+
import type { Callback } from './types.js';
33

44
function noop() {}
55

src/pool.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,11 @@ import DoublyLinked from 'doublylinked';
22
import { EventEmitter } from 'events';
33
import promisify from 'putil-promisify';
44
import { AbortError } from './abort-error.js';
5-
import {
6-
Callback,
7-
PoolConfiguration,
8-
PoolFactory,
9-
PoolState,
10-
ResourceState,
11-
} from './definitions.js';
5+
import { PoolState, ResourceState } from './constants.js';
126
import { PoolOptions } from './pool-options.js';
137
import { PoolRequest } from './pool-request.js';
148
import { ResourceItem } from './resource-item.js';
9+
import type { Callback, PoolConfiguration, PoolFactory } from './types.js';
1510

1611
export class Pool<T = any> extends EventEmitter {
1712
private readonly _options: PoolOptions;

src/resource-item.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { DoublyLinked } from 'doublylinked';
2-
import { ResourceState } from './definitions.js';
1+
import type { DoublyLinked } from 'doublylinked';
2+
import { ResourceState } from './constants.js';
33

44
export class ResourceItem<T> {
55
state: ResourceState = ResourceState.IDLE;

src/definitions.ts renamed to src/types.ts

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,5 @@
11
export type Callback = (e?: unknown, ...args: any[]) => void;
22

3-
export enum PoolState {
4-
IDLE = 0,
5-
STARTED = 1,
6-
CLOSING = 2,
7-
CLOSED = 3,
8-
}
9-
10-
export enum ResourceState {
11-
IDLE = 0,
12-
ACQUIRED = 1,
13-
VALIDATION = 2,
14-
}
15-
163
export interface PoolFactory<T = any> {
174
create(info?: { tries: number; maxRetries: number }): Promise<T> | T;
185

0 commit comments

Comments
 (0)