This function filters inline comments after escaped hashtag

filterCommentInLines(value: (string | array | object)): (string | array | object)
Parameters
value ((string | array | object))
Returns
(string | array | object): filtered value

This function filters comments at line start

filterCommentLines(array: array): array
Parameters
array (array)
Returns
array: filtered value

This function filters empty lines

filterEmptyLines(array: array): array
Parameters
array (array)
Returns
array: filtered value

This function removes quotation marks

removeQuotationMarks(string: string): string
Parameters
string (string)
Returns
string: filtered value

This function parse the Global Super process.env The values in process.env will be parsed by parseValue

getProcessEnv(): object
Returns
object: env

parseEnvironmentFileString

lib/parseEnvironmentFileString.js

This function parse the environment file to an Object

parseEnvironmentFileString(environmentString: string): object
Parameters
environmentString (string)
Returns
object: parsed environment variables

This function parsed

parseValue(value: (object | string)): (object | string)
Parameters
value ((object | string))
Returns
(object | string): value

With processenv2 you have the opportunity to use environment variables directly in your project. You can parse .env files and add them to the global variables process.env. You can also specify default values with processenv2. These values are used if there is no environment variable. This makes it easier to check for errors and use standard configurations.

You also have the option to define nested variables, arrays and objects in the environment file You can use inline comments and masked hashtags (\#)

processenv(key: string?, defaultValue: any?): (string | object | array | function | undefined)
Parameters
key (string?)
defaultValue (any?)
Returns
(string | object | array | function | undefined): value

replaceNestedChars

lib/replaceNestedChars.js

This function parsed nested environment key/value pairs

If the nested element (elem) is present in the environment object (env), this will be parsed and returned as value (val). If the key is not present, the element (elem) is returned as a whole.

replaceNestedChars(elem: string, val: string, env: object): string
Parameters
elem (string) nested element
val (string) the unparsed value
env (object) environment object
Returns
string: ( elem | val )
Example
replaceNestedChars('${HOME}', '${HOME}/log', { HOME: '/var/www' });