https://github.com/simplyhexagonal/elean
Convenience function to parse environment variables to boolean
https://github.com/simplyhexagonal/elean
Last synced: about 1 year ago
JSON representation
Convenience function to parse environment variables to boolean
- Host: GitHub
- URL: https://github.com/simplyhexagonal/elean
- Owner: simplyhexagonal
- Created: 2021-11-09T17:13:10.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2021-11-09T17:20:43.000Z (over 4 years ago)
- Last Synced: 2025-04-27T03:32:59.797Z (about 1 year ago)
- Language: TypeScript
- Size: 60.5 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# Env-var Boolean (elean)

[](https://npm.runkit.com/@simplyhexagonal/elean)
Convenience function to parse environment variables to boolean (perfect companion for [dotenv](https://www.npmjs.com/package/dotenv)).
```ts
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
```ts
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](https://github.com/jeanlescure) 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](#contributors-) ✌️ ! See the [contributing section](#contributing)
## Like this module? ❤
Please consider:
- [Buying me a coffee](https://www.buymeacoffee.com/jeanlescure) ☕
- Supporting Simply Hexagonal on [Open Collective](https://opencollective.com/simplyhexagonal) 🏆
- Starring this repo on [Github](https://github.com/simplyhexagonal/elean) 🌟
## 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](https://allcontributors.org/docs/en/emoji-key)):
## License
Copyright (c) 2021-Present [Package Contributors](https://github.com/simplyhexagonal/elean/#contributors-).
Licensed under the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0).