콘텐츠로 이동

readTextFileLines

이 콘텐츠는 아직 번역되지 않았습니다.

Module @netwiv/api/plugins/fs · Kind Function

import { readTextFileLines } from '@netwiv/api/plugins/fs';

Returns an async {@linkcode AsyncIterableIterator} over the lines of a file, decoded using the specified encoding (default: UTF-8).

function readTextFileLines(path: string | URL, options?: ReadFileOptions | undefined): Promise<AsyncIterableIterator<string>>
import { readTextFileLines, BaseDirectory } from '@netwiv/api/plugins/fs';
const lines = await readTextFileLines('app.conf', { baseDir: BaseDirectory.AppConfig });
for await (const line of lines) {
console.log(line);
}

You could also call {@linkcode AsyncIterableIterator.next} to advance the iterator so you can lazily read the next line whenever you want.

Upstream since 2.0.0


Descriptions come from the pinned @tauri-apps/plugin-fs@2.5.2 declarations (MIT OR Apache-2.0); imports are shown with @netwiv/api paths.