function parseArray
parseArray(text: string): Promise<[string | null, string[][]][]>

Parse an INI string into an array of sections.

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

Each section is represented by a tuple of [sectionName, entries] where sectionName is null for the global section, and entries is an array of [key, value] pairs. Order of sections and entries is preserved.

Examples

Parse INI with global and named sections

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

const text = [
  "global_key=global_value",
  "",
  "[mysection]",
  "key1=1",
  "key2=2",
  "",
].join("\n");

assertEquals(await parseArray(text), [
  [null, [["global_key", "global_value"]]],
  ["mysection", [["key1", "1"], ["key2", "2"]]],
]);

Parameters

text: string

The INI content as a string.

Return Type

Promise<[string | null, string[][]][]>

A promise resolving to an array of section tuples.

Usage

import { parseArray } from "mod.ts";