npm.io
2.0.2 • Published 1 year ago

read-env-value

Licence
MIT
Version
2.0.2
Deps
0
Size
9 kB
Vulns
0
Weekly
0
Stars
2

read-env-value

NPM Version NPM Downloads NPM License JSR JSR Score codecov GitHub Workflow Status PRs Welcome CodeRabbit Pull Request Reviews

Read env with default value

Usage

import { env } from 'read-env-value';

// read env 'NODE_ENV' with default value 'development'
const value = env('NODE_ENV', 'string', 'development');

API

env(key: string, type: 'string' | 'number' | 'boolean', defaultValue?: string | number | boolean)
Parameters
  • key: The environment variable key to read.
  • type: The type of the value to be returned.
  • defaultValue: The default value to return if the environment variable is not set.
Returns
  • The value of the environment variable.
Example
import { env } from 'read-env-value';

const value = env('NODE_ENV', 'string', 'development');

License

MIT

Contributors

Contributors

Made with contributors-img.

Keywords