Env overview

Helpers for working with the environment in Node.js (located at process.env).

Added in v0.9.0


Table of contents


3 Functions

getParam

Attempt to get an environment parameter.

Signature

export declare const getParam: (k: string) => IOOption<string>
getParam :: string -> IOOption string

Example

import { getParam } from 'fp-ts-std/Env'
import * as O from 'fp-ts/Option'

assert.deepStrictEqual(getParam('example')(), O.none)
process.env['example'] = 'ciao'
assert.deepStrictEqual(getParam('example')(), O.some('ciao'))

Added in v0.9.0

getParamNonEmpty

Attempt to get an environment parameter, filtering out empty strings.

Signature

export declare const getParamNonEmpty: (k: string) => IOOption<NonEmptyString>
getParamNonEmpty :: string -> IOOption NonEmptyString

Example

import { getParamNonEmpty } from 'fp-ts-std/Env'
import * as O from 'fp-ts/Option'

assert.deepStrictEqual(getParamNonEmpty('missing')(), O.none)

process.env['non-empty'] = 'ciao'
assert.deepStrictEqual(getParamNonEmpty('non-empty')(), O.some('ciao'))

process.env['empty'] = ''
assert.deepStrictEqual(getParamNonEmpty('empty')(), O.none)

Added in v0.9.0