Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

std/io/read_lines.ts>readLines

The Deno Standard Library
Go to Latest
The Standard Library has been moved to JSR. See the blog post for details.
function readLines
Deprecated
Deprecated

(will be removed after 1.0.0) Use the Web Streams API instead.

import { readLines } from "https://deno.land/std@0.222.1/io/read_lines.ts";

Read strings line-by-line from a Reader.

Examples

Example 1

import { readLines } from "https://deno.land/std@0.222.1/io/read_lines.ts";
import * as path from "https://deno.land/std@0.222.1/path/mod.ts";

const filename = path.join(Deno.cwd(), "std/io/README.md");
let fileReader = await Deno.open(filename);

for await (let line of readLines(fileReader)) {
  console.log(line);
}

Parameters

reader: Reader
optional
decoderOpts: { encoding?: string; fatal?: boolean; ignoreBOM?: boolean; }

Returns

AsyncIterableIterator<string>