@simplyhexagonal/elean
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

Env-var Boolean (elean)

Tests Try elean on RunKit

Convenience function to parse environment variables to boolean (perfect companion for dotenv).

require('dotenv').config();

import elean from '@simplyhexagonal/elean';

const { MY_ENV_VAR } = process.env;

elean(MY_ENV_VAR); // returns either true or false

Tested evaluations

elean('') // false
elean(0) // false
elean('0') // false
elean(null) // false
elean('null') // false
elean('NULL') // false
elean(false) // false
elean('false') // false
elean('FALSE') // false
elean(undefined) // false
elean('undefined') // false

// ---

elean(1) // true
elean('1') // true
elean('xyz') // true
elean(true) // true
elean('true') // true
elean('TRUE') // true

Open source notice

This project is open to updates by its users, I ensure that PRs are relevant to the community. In other words, if you find a bug or want a new feature, please help us by becoming one of the contributors ✌️ ! See the contributing section

Like this module?

Please consider:

Contributing

Yes, thank you! This plugin is community-driven, most of its features are from different authors. Please update the docs and tests and add your name to the package.json file.

Contributors

Thanks goes to these wonderful people (emoji key):


Jean Lescure

🚧 💻 📓 ⚠️ 💡 📖

License

Copyright (c) 2021-Present Package Contributors.
Licensed under the Apache License 2.0.

Package Sidebar

Install

npm i @simplyhexagonal/elean

Weekly Downloads

230

Version

1.0.0

License

Apache-2.0

Unpacked Size

8.01 kB

Total Files

8

Last publish

Collaborators

  • jeanlescure