function encodeSectionStream
encodeSectionStream(stream: ReadableStream<IniSection>): ReadableStream<string>

Encode a stream of INI sections into text lines.

Transforms a stream of IniSection objects into a stream of text lines. Each section is expanded into its header line (if not global) followed by its entry lines.

Examples

Encode sections to text lines

import { encodeSectionStream } from "@hertzg/wg-ini";
import type { IniSection } from "@hertzg/wg-ini/sections";
import { assertEquals } from "@std/assert";

const sections: IniSection[] = [{
  section: { $section: "mysection" },
  entries: [{ $assign: ["key", "value"] as [string, string], $comment: null }],
}];
const stream = ReadableStream.from(sections);
const lines = await Array.fromAsync(encodeSectionStream(stream));

assertEquals(lines, ["[mysection]", "key=value"]);

Parameters

A readable stream of INI section objects.

Return Type

A readable stream of text lines.

Usage

import { encodeSectionStream } from "mod.ts";