Skip to content

Commit 935c12a

Browse files
committed
feat: simplify LogWriter interface
1 parent 0f76d74 commit 935c12a

3 files changed

Lines changed: 8 additions & 9 deletions

File tree

src/factories/createNodeWriter.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@ import type {
33
} from '../types';
44

55
const createBlockingWriter = (stream: NodeJS.WritableStream): LogWriter => {
6-
return {
7-
write: (message: string) => {
8-
stream.write(message + '\n');
9-
},
6+
return (message: string) => {
7+
stream.write(message + '\n');
108
};
119
};
1210

src/factories/createRoarrInitialGlobalState.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ export const createRoarrInitialGlobalState = (currentState: any): RoarrGlobalSta
3939

4040
newState = {
4141
...newState,
42-
...createNodeWriter(),
42+
...{
43+
write: createNodeWriter(),
44+
},
4345
asyncLocalStorage,
4446
};
4547
// eslint-disable-next-line no-empty

src/types.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,15 @@ import type {
22
AsyncLocalStorage,
33
} from 'async_hooks';
44

5-
export type LogWriter = {
6-
write: (message: string) => void,
7-
};
5+
export type LogWriter = (message: string) => void;
86

97
export type MessageContext = any;
108

11-
export type RoarrGlobalState = LogWriter & {
9+
export type RoarrGlobalState = {
1210
asyncLocalStorage?: AsyncLocalStorage<MessageContext>,
1311
sequence: number,
1412
versions: readonly string[],
13+
write: LogWriter,
1514
};
1615

1716
export type SprintfArgument = boolean | number | string | null;

0 commit comments

Comments
 (0)