A transform stream that encodes INI line objects back into text lines.
This is the reverse of IniLineDecoderStream. It converts structured IniLine objects back into their string representation, preserving comments and trailers.
Encode INI line objects to text
Encode INI line objects to text
import { assertEquals } from "@std/assert"; import { IniLineEncoderStream, type IniLine } from "@hertzg/wg-ini/lines"; const stream = ReadableStream.from([ { $comment: " comment outside of section" }, { $assign: ["global_key", "global_value "], $comment: " with comment" }, { $trailer: "" }, { $section: "mysection" }, { $assign: ["key1", "1"] }, { $assign: ["key2", "2"] }, { $trailer: "" }, { $section: "mysection", $trailer: " # and a comment" }, { $assign: ["key1", "3"] }, { $assign: ["key2", "4"] }, { $trailer: "" }, ] as IniLine[]).pipeThrough(new IniLineEncoderStream()); const lines = await Array.fromAsync(stream); assertEquals(lines, [ "# comment outside of section", "global_key=global_value # with comment", "", "[mysection]", "key1=1", "key2=2", "", "[mysection] # and a comment", "key1=3", "key2=4", "", ]);
IniLineEncoderStream(options?: IniLineEncoderStreamOptions)
Create a new INI line encoder stream.
Parameters
optional
options: IniLineEncoderStreamOptions
Configuration options for encoding delimiters.