mentalist

2.0.1 • Public • Published

mentalist

Environment variable parsing for configuring applications.

Build Status

installation

$ npm i mentalist

introduction

This module is intended to be used to load a configuration when you store parameters in environment variables. Several parse methods are provided to read, parse and default a configuration value. All parsing methods will throw when a variable is not defined and no default is specified. Don't like this behavior? Always specify a default value, use undefined for default in case you want it to be optional.

API

var mentalist = require("mentalist");

Existence

if (mentalist.has(variableName)) {
  // ...
}

Checks for existence of a variable in the environment.

Booleans

var myBool = mentalist.bool(variableName, [default]);

Reads in and parses a boolean environment variable and provides a default if not found. If default is not specified the function throws when the variable doesn't exist.

Numbers

var myNumber = mentalist.number(variableName, [default]);

Reads in and parses a numerical environment variable and provides a default if not found. If default is not specified the function throws when the variable doesn't exist.

Strings

var myString = mentalist.string(variableName, [default]);

Reads in a string environment variable and provides a default if not found. If default is not specified the function throws when the variable doesn't exist.

Objects

var myobject = mentalist.object(variableName, [default]);

Reads in an object from an environment variable and provides a default if not found. If default is not specified the function throws when the variable doesn't exist.

Package Sidebar

Install

npm i mentalist

Weekly Downloads

1

Version

2.0.1

License

MIT

Unpacked Size

23.6 kB

Total Files

13

Last publish

Collaborators

  • janpotoms