parse

import { parse } from "jsr:@ende/dotenv";

function

function parse(text: string): Record<string, string>

Parse .env file output in an object.

Note: The key needs to match the pattern /^[a-zA-Z_][a-zA-Z0-9_]*$/. Double-quoted values expand \n, \r, \t, \", \', and \\ escape sequences.

text: string

The text to parse.

Returns

The parsed object.

Example: Usage

import { parse } from "@ende/dotenv/parse";
import { assertEquals } from "@ende/assert";

const env = parse("GREETING=hello world");
assertEquals(env, { GREETING: "hello world" });

Source