2.0.1 • Published 3 years ago

mentalist v2.0.1

Weekly downloads
74
License
MIT
Repository
github
Last release
3 years ago

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.

2.0.1

3 years ago

2.0.0

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago

0.1.4

9 years ago

0.1.3

9 years ago

0.1.2

9 years ago

0.1.1

9 years ago

0.1.0

9 years ago

0.0.1

9 years ago