https://github.com/grimen/node-env-flag
Little util function for simpler extracting Boolean values from ENV variables in Node.js.
https://github.com/grimen/node-env-flag
boolean booleans env false flag flags process true
Last synced: 22 days ago
JSON representation
Little util function for simpler extracting Boolean values from ENV variables in Node.js.
- Host: GitHub
- URL: https://github.com/grimen/node-env-flag
- Owner: grimen
- License: mit
- Created: 2013-05-14T16:46:43.000Z (about 12 years ago)
- Default Branch: master
- Last Pushed: 2023-01-05T03:47:13.000Z (over 2 years ago)
- Last Synced: 2024-11-03T18:38:45.938Z (7 months ago)
- Topics: boolean, booleans, env, false, flag, flags, process, true
- Language: JavaScript
- Homepage: https://npmjs.org/package/node-env-flag
- Size: 1.05 MB
- Stars: 8
- Watchers: 3
- Forks: 1
- Open Issues: 17
-
Metadata Files:
- Readme: README.md
- License: MIT-LICENSE
Awesome Lists containing this project
README
# NODE-ENV-FLAG [](https://badge.fury.io/js/node-env-flag) [](http://travis-ci.org/grimen/node-env-flag) [](https://codecov.io/gh/grimen/node-env-flag)
Little util function for simpler extracting `Boolean` values from `ENV` variables in Node.js, i.e. `true` values (`true`, `TRUE`, `1`) vs. `false` values (`false`, `FALSE`, `0`).
## Example
```javascript
const DEFAULT_FOO = 1const flag = require('node-env-flag')
const yep = flag(process.env.FOO, DEFAULT_FOO)
if (yep) {
console.log("Foo!")
}
```## API
* `(value)`
```javascript
flag(process.env.FOO);
```* `(value, default)`
```javascript
flag(process.env.FOO, 1);
```## Installation
```shell
$ npm install node-env-flag
```## Test
**Local tests:**
```shell
$ make test
```## License
Released under the MIT license.
Copyright (c) [Jonas Grimfelt](http://github.com/grimen)