Skip to content

Commit da5a447

Browse files
committed
feat: update readFileByLine to return AsyncIterable instead of AsyncIterator
1 parent 6d9db73 commit da5a447

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/fs/safe.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -205,10 +205,10 @@ export function readFileSync(path: any, options?: any): Result<any, Error> {
205205
});
206206
}
207207

208-
export const readFileByLine = async (
208+
export const readFileByLine = (
209209
path: PathLike,
210210
options?: StringEncodingOptions,
211-
): Promise<Result<AsyncIterator<string>, Error>> =>
211+
): Promise<Result<AsyncIterable<string>, Error>> =>
212212
safeTry(async function* () {
213213
yield* await exists(path);
214214

@@ -228,7 +228,7 @@ export const readFileByLine = async (
228228
crlfDelay: Infinity,
229229
});
230230

231-
return reader[Symbol.asyncIterator]();
231+
return reader;
232232
};
233233
const result = Result.fromCallable(fn, Error).context(`Failed to read file: ${path}`);
234234

src/fs/unsafe.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ export function readFileSync(path: any, options?: any): any {
102102
export const readFileByLine = async (
103103
path: PathLike,
104104
options?: StringEncodingOptions,
105-
): Promise<AsyncIterator<string> | undefined> => {
105+
): Promise<AsyncIterable<string> | undefined> => {
106106
const result = await safeReadFileByLine(path, options);
107107
if (result.isErr()) return undefined;
108108

0 commit comments

Comments
 (0)