Skip to content

Commit 65eb8e7

Browse files
authored
fix: replace Duplex with a Transform (#40)
1 parent dd6d3bd commit 65eb8e7

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/index.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { EventEmitter } from 'events';
22
import path from 'path';
33
import { vinylFileSync } from 'vinyl-file';
44
import File from 'vinyl';
5-
import { type PipelineTransform, Readable, Duplex } from 'stream';
5+
import { type PipelineTransform, Readable, Transform } from 'stream';
66
import { pipeline } from 'stream/promises';
77

88
// eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -31,14 +31,14 @@ export function isFileTransform<StoreFile extends { path: string } = File>(
3131

3232
export function loadFile(filepath: string): File {
3333
try {
34-
return vinylFileSync(filepath);
34+
return vinylFileSync(filepath) as unknown as File;
3535
} catch (err) {
3636
return new File({
3737
cwd: process.cwd(),
3838
base: process.cwd(),
3939
path: filepath,
4040
contents: null,
41-
});
41+
}) as unknown as File;
4242
}
4343
}
4444

@@ -155,10 +155,12 @@ export class Store<StoreFile extends { path: string } = File> extends EventEmitt
155155
Readable.from(iterablefilter(this.store.values())) as any,
156156
// eslint-disable-next-line @typescript-eslint/no-explicit-any
157157
...(transforms as any),
158-
Duplex.from(async (generator: AsyncGenerator<StoreFile>) => {
159-
for await (const file of generator) {
158+
new Transform({
159+
objectMode: true,
160+
transform(file: StoreFile, _encoding, callback) {
160161
addFile?.(file);
161-
}
162+
callback(null);
163+
},
162164
}),
163165
);
164166

0 commit comments

Comments
 (0)