1.0.0 • Published 2 years ago

@simplyhexagonal/elean v1.0.0

Weekly downloads
-
License
Apache-2.0
Repository
-
Last release
2 years ago

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):

License

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