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.
Decode and encode INI lines
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);
A transform stream that decodes lines of an INI file into structured objects.
A transform stream that encodes INI line objects back into text lines.
Configuration options for IniLineDecoderStream.
-
commentDelimiter: string
Delimiter for comments (default:
"#"). -
keyValueDelimiter: string
Delimiter for key-value pairs (default:
"="). -
sectionEndDelimiter: string
Delimiter for section end (default:
"]"). -
sectionStartDelimiter: string
Delimiter for section start (default:
"[").
Configuration options for IniLineEncoderStream.
-
commentDelimiter: string
Delimiter for comments (default:
"#"). -
keyValueDelimiter: string
Delimiter for key-value pairs (default:
"="). -
sectionEndDelimiter: string
Delimiter for section end (default:
"]"). -
sectionStartDelimiter: string
Delimiter for section start (default:
"[").
| IniLineAssign
| IniLineComment
| IniLineTrailer
Union type for all INI line types.
Represents an INI key-value assignment line (e.g., key=value).
Represents an INI comment line (e.g., # comment).
Represents an INI section header line (e.g., [section]).
Represents an INI trailer line (empty lines or unrecognized content).
Usage
import * as mod from "lines.ts";