New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

parse-env-string

Package Overview
Dependencies
Maintainers
2
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

parse-env-string

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

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2.5K
decreased by-47.64%
Maintainers
2
Weekly downloads
 
Created
Source

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

Keywords

FAQs

Package last updated on 22 Sep 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc