Link Search Menu Expand Document

Env overview

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

Added in v0.9.0


Table of contents


utils

getParam

Attempt to get an environment parameter.

Signature

export declare const getParam: (k: string) => IO<Option<string>>
getParam :: string -> IO (Option 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) => IO<Option<string>>
getParamNonEmpty :: string -> IO (Option string)

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