Transform streams for encoding and decoding individual lines of an INI file.

This module provides low-level stream transformers that work with individual lines of INI text. Use IniLineDecoderStream to parse text lines into structured IniLine objects, and IniLineEncoderStream to convert them back to text.

For higher-level section-based processing, see the sections module. For convenient parse/stringify functions, see the main module.

Examples

Decode and encode INI lines

import { assertEquals } from "@std/assert";
import { IniLineDecoderStream, IniLineEncoderStream } from "@hertzg/wg-ini/lines";

const lines = ["[section]", "key=value"];
const decoded = await Array.fromAsync(
  ReadableStream.from(lines).pipeThrough(new IniLineDecoderStream())
);

assertEquals(decoded, [
  { $section: "section", $trailer: "" },
  { $assign: ["key", "value"], $comment: null },
]);

const encoded = await Array.fromAsync(
  ReadableStream.from(decoded).pipeThrough(new IniLineEncoderStream())
);

assertEquals(encoded, lines);

Classes

c
IniLineDecoderStream(options?: IniLineDecoderStreamOptions)

A transform stream that decodes lines of an INI file into structured objects.

c
IniLineEncoderStream(options?: IniLineEncoderStreamOptions)

A transform stream that encodes INI line objects back into text lines.

Interfaces

I
IniLineDecoderStreamOptions

Configuration options for IniLineDecoderStream.

I
IniLineEncoderStreamOptions

Configuration options for IniLineEncoderStream.

Type Aliases

T
IniLineComment = { $comment: string; }

Represents an INI comment line (e.g., # comment).

T
IniLineTrailer = { $trailer: string; }

Represents an INI trailer line (empty lines or unrecognized content).