method Enumerable.prototype.lines
Enumerable.prototype.lines(): Lines<T>

Convert byte stream to text lines.

Important: This is a property, not a method. Use .lines not .lines().

Returns an Enumerable<string> where each item is a line of text. Lines are split on \n or \r\n. Line endings are not included in the output.

Note that this should probably only be used with small data. Consider chunkedLines to improve performance with larger data.

Examples

Get lines from process output

import { run } from "jsr:@j50n/proc";

const lines = await run("ls", "-la").lines.collect();
// Array of strings, one per line

Process lines with transformations

import { run } from "jsr:@j50n/proc";

const numbers = await run("echo", "-e", "1\\n2\\n3")
  .lines
  .map(line => parseInt(line))
  .collect();
// [1, 2, 3]

Return Type

Lines<T>

Usage

import { Enumerable } from ".";