parse-env-string
DefinitelyTyped icon, indicating that this package has TypeScript declarations provided by the separate @types/parse-env-string package

1.0.1 • Public • Published

parse-env-string

Parse a string containing environment variables to a key/value object.

npm Test status js-standard-style

Installation

npm install parse-env-string --save

Usage

const parseEnvString = require('parse-env-string')

const env = parseEnvString('foo=hello bar= baz=", world"') 

assert.deepStrictEqual(env, {
  foo: 'hello',
  bar: '',
  baz: ', world'
})

API

This modules exposes a single function:

parseEnvString([string])

It takes a string and returns an object. If given null or undefined an empty object is returned. If given anything else, a TypeError is thrown.

An Error will also be thrown if the provided string doesn't contain valid environment variables. E.g. if given the string 1a=b, an error will be thrown because environment variables cannot have a digit as the first character.

License

MIT

Dependencies (0)

    Dev Dependencies (2)

    Package Sidebar

    Install

    npm i parse-env-string

    Weekly Downloads

    3,381

    Version

    1.0.1

    License

    MIT

    Unpacked Size

    6.86 kB

    Total Files

    4

    Last publish

    Collaborators

    • trentm
    • watson