function stringifyArray
stringifyArray(array: [string | null, string[][]][]): Promise<string>

Convert an array of sections to an INI string.

Since it takes an array, it supports duplicate keys and sections. This is the reverse of parseArray.

Each section must be a tuple of [sectionName, entries] where sectionName is null for the global section, and entries is an array of [key, value] pairs. The global section is always placed first in the output.

Examples

Stringify array with global and named sections

import { stringifyArray } from "@hertzg/wg-ini";
import { assertEquals } from "@std/assert";

const array: [string | null, string[][]][] = [
  [null, [["global_key", "global_value"]]],
  ["mysection", [["key1", "1"], ["key2", "2"]]],
];

assertEquals(await stringifyArray(array), [
  "global_key=global_value",
  "",
  "[mysection]",
  "key1=1",
  "key2=2",
  "",
].join("\n"));

Parameters

array: [string | null, string[][]][]

An array of section tuples to stringify.

Return Type

Promise<string>

A promise resolving to the INI content as a string.

Usage

import { stringifyArray } from "mod.ts";